'공부'에 해당되는 글 26건

pyqt-python

pyqt 2016. 2. 5. 13:39

pyqt파일을 python파일로 바꾸는 방법

winow key+r클릭 후 창에 접속


밑의 사진과 같이 pyuic4 -x C:\Users\hyj15\Desktop\만든 파일 이름.ui -o C:\Users\hyj15\Desktop\t원하는 파일 이름.py를 치고 엔터키를 쳐준다.

바탕화면을 보게 되면 저는 title이라는 파일이 생성되어있습니다.



그 파일을 파이썬 파일로 불러오게 되면 위와 같은 사진 처럼 뜨게 됩니다.


'pyqt' 카테고리의 다른 글

file open  (0) 2016.02.02
text editor  (0) 2016.02.02
progress bar2  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
블로그 이미지

유정쓰

,

tk listbox-2

python 2016. 2. 2. 16:26

activestyle [default value:'underline']

Listbox에서 선택된 아이템의 표시형태를 지정한다.

dotbox값은 선택된 아이템에 점선테두리효과를 준다.

none값은 선택된 아이템에 블록 처리 외에 아무런 효과를 주지 않는다.

underline값은 선택된 아이템의 문자열에 밑줄효과를 준다.

: 'dotbox', 'none', 'underline'

 

background = bg [default value:'SystemWindow'] : color

Listbox위젯의 배경색

 

borderwidth = bd [default value:1] : mm/pixel

Listbox위젯의 테두리두께

 

cursor [default value:'']

Listbox위젯의 마우스커서모양

: "arrow", "circle", "clock", "cross", "dotbox", "exchange", "fleur", "heart", "heart", "man", "mouse", "pirate", "plus", "shuttle", "sizing", "spider", "spraycan", "star", "target", "tcross", "trek", "watch" 등등

 

disabledforeground [default value:'SystemDisabledText'] : color

Listbox위젯이 disabled상태일때 위젯의 문자열 색

 

exportselection [default value:1] : boolean

 

font [default value:'TkDefaultFont'] : font

Listbox위젯에 표시할 문자열의 글꼴

값으로는 font객체가 사용되며, 글꼴객체생성방법은 아래 URL을 참조하길 바란다.

http://blog.naver.com/dudwo567890/130167555486

 

foreground = fg [default value:'SystemButtonText'] : color

Listbox위젯의 문자열 색

 

height [default value:10] : number of characters

Listbox위젯의 세로크기

값을 0으로 주면 아이템의 개수에 맞춰서 Listbox의 크기가 자동으로 조절된다.

 

highlightbackground [default value:'SystemButtonFace'] : color

Listbox위젯이 선택되지 않았을 때의 하이라이트 색

 

highlightcolor [default value:'SystemWindowFrame'] : color

Listbox위젯이 선택되었을 때의 하이라이트색

 

highlightthickness [default value:1] : mm/pixel

Listbox위젯이 선택되었을 때와 선택되지 않았을 때를 구분하는 하이라이트의 두께

 

listvariable [default value:''] :

Listbox위젯의 항목을 저장하는 Tk변수(StringVar)

Tk변수를 이용하여 Listbox에 항목을 입력할 수도 있고,

Listbox에 항목을 입력하여 Tk변수에 저장할 수도 있다.

 

relief [default value:'sunken']

Listbox위젯의 테두리모양

: "flat", "groove", "raised", "ridge", "solid", "sunken"

 

selectbackground [default value:'SystemHighlight'] : color

Libox위젯의 항목을 선택 할 때 블록처리 되는 부분의 배경색상

 

selectborderwidth [default value:0] : mm/pixel

Listbox위젯의 항목을 선택할 때 블럭처리되는 부분의 테두리두께

 

selectforeground [default value:'SystemHighlightText'] : color

Listbox위젯의 항목을 선택할 때 블럭처리되는 부분의 문자열 색

 

-. selectmode [default value:'browse']

: 'single', 'browse', 'multiple', 'extend'

 

-. setgrid [default value:0]

 

-. state [default value:'normal']

Listbox위젯의 상태 값

: 'disabled', 'normal

 

-. takefocus [default value:'']

 

-. width [default value:20] : number of characters

Listbox위젯의 가로크기

값을 0으로 주면 문자열의 길이에 맞춰서 Listbox의 크기가 자동으로 조절된다.

 

-. xscrollcommand [default value:''] :

Listbox위젯에 가로스크롤을 사용하고 싶을 때 Scrollbar객체를 지정하여 사용

 

-. yscrollcommand [default value:''] :

Listbox위젯에 세로스크롤을 사용하고 싶을 때 Scrollbar객체를 지정하여 사용

 

'python' 카테고리의 다른 글

tk listbox  (0) 2016.02.02
연달아 창 띄우기  (0) 2016.02.02
python gmail보내기  (0) 2016.02.01
tkninter tk  (0) 2016.01.28
Tkinter 기초  (0) 2016.01.28
블로그 이미지

유정쓰

,

tk listbox

python 2016. 2. 2. 16:18
from tkinter import*

root=Tk()


listbox=Listbox(root)


listbox.insert(1,"Python")
listbox.insert(
2,"c++")
listbox.insert(
3,"c#")
listbox.insert(
4,"java")
listbox.insert(
5,"php")
listbox.insert(
6,"html")
listbox.insert(
7,"css")
listbox.insert(
8,"arduino")
listbox.pack()


root.mainloop()

 

 

'python' 카테고리의 다른 글

tk listbox-2  (0) 2016.02.02
연달아 창 띄우기  (0) 2016.02.02
python gmail보내기  (0) 2016.02.01
tkninter tk  (0) 2016.01.28
Tkinter 기초  (0) 2016.01.28
블로그 이미지

유정쓰

,

연달아 창 띄우기

python 2016. 2. 2. 15:35

# -*- coding : cp949 -*-

from tkinter import *

class App:
   
def __init__(self, root, use_geometry, show_buttons):
       fm=Frame(root,
width=300, height=300, bg="blue")
        fm.pack(
side=TOP, expand=NO, fill=NONE)
       
if use_geometry:
            root.geometry(
"600x600")

       
if show_buttons:

            Button(fm,
text="안녕",width=10).pack(side=LEFT)
            Button(fm,
text="하세요",width=10).pack(side=LEFT)
            Button(fm,
text="반가워요.",width=10).pack(side=LEFT)
#버튼의 이름


case=0

for use_geometry in (0,1):

   
for show_buttons in (0,1):

        case = case +
1

       
root=Tk()
        root.wm_title(
"Case " + str(case)) #창의 제목
       
display=App(root, use_geometry, show_buttons)
        root.mainloop()

 

하나를 끄면 그 다음 창이 뜨게 되는 구조

 

 

'python' 카테고리의 다른 글

tk listbox-2  (0) 2016.02.02
tk listbox  (0) 2016.02.02
python gmail보내기  (0) 2016.02.01
tkninter tk  (0) 2016.01.28
Tkinter 기초  (0) 2016.01.28
블로그 이미지

유정쓰

,

file open

pyqt 2016. 2. 2. 09:59

 

openFile = QtGui.QAction("&Open File", self)
        openFile.setShortcut("Ctrl+O")
        openFile.setStatusTip('Open File')
        openFile.triggered.connect(self.file_open)

        fileMenu.addAction(file_open)

    def file_open(self):
        name = QtGui.QFileDialog.getOpenFileName(self, 'Open File')
        file = open(name,'r')

        self.editor()

        with file:
            text = file.read()
            self.textEdit.setText(text)

 

 

위 사진은 파일열기를 넣은 것을 확인해보기 위해서 텍스트 파일을 하나 열어보았습니다.

워드 파일은 열리질 않네요:-)

'pyqt' 카테고리의 다른 글

pyqt-python  (0) 2016.02.05
text editor  (0) 2016.02.02
progress bar2  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
블로그 이미지

유정쓰

,

text editor

pyqt 2016. 2. 2. 09:47

text를 편집할 수 있는 창입니다.

 

     openEditor = QtGui.QAction('&Editor', self)
        openEditor.setShortcut('Ctrl+E')
        openEditor.setStatusTip('Open Editor')
        openEditor.triggered.connect(self.editor)
       
        editorMenu = mainMenu.addMenu('&Editor')
        editorMenu.addAction(openEditor)
    def editor(self):
        self.textEdit = QtGui.QTextEdit()
        self.setCentralWidget(self.textEdit)

 

'pyqt' 카테고리의 다른 글

pyqt-python  (0) 2016.02.05
file open  (0) 2016.02.02
progress bar2  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
블로그 이미지

유정쓰

,

progress bar2

pyqt 2016. 2. 2. 09:39

self.styleChoice = QtGui.QLabel("Windows Vista", self)
self.styleChoice.move(50,150)

        comboBox = QtGui.QComboBox(self)
        comboBox.addItem("motif")
        comboBox.addItem("Windows")
        comboBox.addItem("cde")
        comboBox.addItem("Plastique")
        comboBox.addItem("Cleanlooks")
        comboBox.addItem("windowsvista")
        comboBox.move(50, 250)

        comboBox.activated[str].connect(self.style_choice)

 def styleChoice(self, text):
        self.stylechoice.setText(text)
        QtGui.QApplication.setStyle(QtGui.QStyleFactory.create(text))

qstylefactory를 사용하였습니다.

회색으로 표시한 부분이 바뀌게 되면서 바 스타일도 바뀌게 됩니다.

 

 

'pyqt' 카테고리의 다른 글

file open  (0) 2016.02.02
text editor  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
pyqt 예제  (0) 2016.02.01
블로그 이미지

유정쓰

,

progress bar

pyqt 2016. 2. 2. 09:32

 

위와 같이 다운로드 창을 만드는 방법 입니다. 100퍼센트가 찰 경우 초록색으로 칸이 다 차는 방식입니다.

 

        self.progress = QtGui.QProgressBar(self)
        self.progress.setGeometry(200, 80, 250, 20)

        self.btn = QtGui.QPushButton("Download",self)
        self.btn.move(200,120)
        self.btn.clicked.connect(self.download)


def download(self):
        self.completed = 0

        while self.completed < 100:
            self.completed += 0.0001
            self.progress.setValue(self.completed)

'pyqt' 카테고리의 다른 글

text editor  (0) 2016.02.02
progress bar2  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
pyqt 예제  (0) 2016.02.01
pyqt-button  (0) 2016.02.01
블로그 이미지

유정쓰

,

pyqt 예제2

pyqt 2016. 2. 1. 16:32
import sys
from PyQt4 import QtGui, QtCore

class Window(QtGui.QMainWindow):

 

def __init__(self):
super(Window, self).__init__()
self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("PyQT tuts!")


extractAction = QtGui.QAction("&GET TO THE CHOPPAH!!!", self)
extractAction.setShortcut("Ctrl+Q")
extractAction.setStatusTip('Leave The App')
extractAction.triggered.connect(self.close_application)

openEditor = QtGui.QAction("&Editor", self)
openEditor.setShortcut("Ctrl+E")
openEditor.setStatusTip('Open Editor')
openEditor.triggered.connect(self.editor)

openFile = QtGui.QAction("&Open File", self)
openFile.setShortcut("Ctrl+O")
openFile.setStatusTip('Open File')
openFile.triggered.connect(self.file_open)

self.statusBar()

mainMenu = self.menuBar()

fileMenu = mainMenu.addMenu('&File')
fileMenu.addAction(extractAction)
fileMenu.addAction(openFile)

editorMenu = mainMenu.addMenu("&Editor")
editorMenu.addAction(openEditor)

self.home()



def home(self):
btn = QtGui.QPushButton("Quit", self)
btn.clicked.connect(self.close_application)
btn.resize(btn.minimumSizeHint())
btn.move(0,100)

extractAction = QtGui.QAction('Flee the Scene', self)
extractAction.triggered.connect(self.close_application)
self.toolBar = self.addToolBar("Extraction")
self.toolBar.addAction(extractAction)



fontChoice = QtGui.QAction('Font', self)
fontChoice.triggered.connect(self.font_choice)
#self.toolBar = self.addToolBar("Font")
self.toolBar.addAction(fontChoice)

color = QtGui.QColor(0, 0, 0)

fontColor = QtGui.QAction('Font bg Color', self)
fontColor.triggered.connect(self.color_picker)

self.toolBar.addAction(fontColor)



checkBox = QtGui.QCheckBox('Enlarge Window', self)
checkBox.move(300, 25)
checkBox.stateChanged.connect(self.enlarge_window)

self.progress = QtGui.QProgressBar(self)
self.progress.setGeometry(200, 80, 250, 20)

self.btn = QtGui.QPushButton("Download",self)
self.btn.move(200,120)
self.btn.clicked.connect(self.download)

#print(self.style().objectName())
self.styleChoice = QtGui.QLabel("Windows Vista", self)

comboBox = QtGui.QComboBox(self)
comboBox.addItem("motif")
comboBox.addItem("Windows")
comboBox.addItem("cde")
comboBox.addItem("Plastique")
comboBox.addItem("Cleanlooks")
comboBox.addItem("windowsvista")

comboBox.move(50, 250)
self.styleChoice.move(50,150)
comboBox.activated[str].connect(self.style_choice)

cal = QtGui.QCalendarWidget(self)
cal.move(500,200)
cal.resize(200,200)

self.show()

//파일 오픈 소스


def file_open(self):
name = QtGui.QFileDialog.getOpenFileName(self, 'Open File')
file = open(name,'r')

self.editor()

with file:
text = file.read()
self.textEdit.setText(text)
//색상

def color_picker(self):
color = QtGui.QColorDialog.getColor()
self.styleChoice.setStyleSheet("QWidget { background-color: %s}" % color.name())
//편집기능

def editor(self):
self.textEdit = QtGui.QTextEdit()
self.setCentralWidget(self.textEdit)
//폰트 고르기


def font_choice(self):
font, valid = QtGui.QFontDialog.getFont()
if valid:
self.styleChoice.setFont(font)


def style_choice(self, text):
self.styleChoice.setText(text)
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create(text))
//다운로드 표시창

def download(self):
self.completed = 0

while self.completed < 100:
self.completed += 0.0001
self.progress.setValue(self.completed)

//커지는 창

def enlarge_window(self, state):
if state == QtCore.Qt.Checked:
self.setGeometry(50,50, 1000, 600)
else:
self.setGeometry(50, 50, 500, 300)




def close_application(self):
choice = QtGui.QMessageBox.question(self, 'Extract!',
"Get into the chopper?",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice == QtGui.QMessageBox.Yes:
print("Extracting Naaaaaaoooww!!!!")
sys.exit()
else:
pass



def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())
 



run()

 

'pyqt' 카테고리의 다른 글

progress bar2  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제  (0) 2016.02.01
pyqt-button  (0) 2016.02.01
pyqt 창 띄우기  (0) 2016.02.01
블로그 이미지

유정쓰

,

pyqt 예제

pyqt 2016. 2. 1. 15:23
import sys
from PyQt4 import QtGui, QtCore

class Window(QtGui.QMainWindow):
 


def __init__(self):
super(Window, self).__init__()
self.setGeometry(50, 50, 500, 300)
self.setWindowTitle("Test")

extractAction = QtGui.QAction("&test file", self)
extractAction.setShortcut("Ctrl+T")/단축기
extractAction.setStatusTip('Leave The App')
extractAction.triggered.connect(self.close_application)

self.statusBar()

mainMenu = self.menuBar()
fileMenu = mainMenu.addMenu('&File')
fileMenu.addAction(extractAction)


self.home()

 

 



def home(self):
btn = QtGui.QPushButton("Quit", self)
btn.clicked.connect(self.close_application)
btn.resize(btn.minimumSizeHint())
btn.move(100,0)

extractAction = QtGui.QAction('뭘봐 ', self)
extractAction.triggered.connect(self.close_application)

self.toolBar = self.addToolBar("Extraction")
self.toolBar.addAction(extractAction)

checkBox = QtGui.QCheckBox('누르지마', self)
checkBox.move(100, 18)
checkBox.stateChanged.connect(self.enlarge_window)

self.progress = QtGui.QProgressBar(self)
self.progress.setGeometry(200, 80, 250, 20)

self.btn = QtGui.QPushButton("Download",self)
self.btn.move(200,120)
self.btn.clicked.connect(self.download)

self.show()


   def download(self):
self.completed = 0

while self.completed < 100:
self.completed += 0.0001
self.progress.setValue(self.completed)



  def enlarge_window(self, state):
if state == QtCore.Qt.Checked:
self.setGeometry(50,50, 1000, 600)
else:
self.setGeometry(50, 50, 500, 300)



   def close_application(self):
choice = QtGui.QMessageBox.question(self, '누르냐?!',
"꺼져",
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if choice == QtGui.QMessageBox.Yes:
print("hihihihihihihihihi")
sys.exit()
else:
pass


 
def run():
app = QtGui.QApplication(sys.argv)
GUI = Window()
sys.exit(app.exec_())


run()

실행시 뜨는 창

 

 

누르지마를 클릭 할시 뜨는 창

 

 

 

 

'pyqt' 카테고리의 다른 글

progress bar2  (0) 2016.02.02
progress bar  (0) 2016.02.02
pyqt 예제2  (0) 2016.02.01
pyqt-button  (0) 2016.02.01
pyqt 창 띄우기  (0) 2016.02.01
블로그 이미지

유정쓰

,