├── Codes ├── 01-PyQt-GUI-Programming-Tutorial │ ├── GroupBox.py │ ├── Progressbar.py │ ├── QCheckBox.py │ ├── QDial.py │ ├── QLineEdit.py │ ├── QMessageBox.py │ ├── QPixmap.py │ ├── QSlider.py │ ├── QToolBox01.py │ ├── QToolBox02.py │ ├── QVboxLayout .py │ ├── TabWidget.py │ ├── Tables.py │ ├── Toolbar.py │ ├── autoComplete.py │ ├── buttons.py │ ├── combobox.py │ ├── grid.py │ ├── helloWorld.py │ ├── images │ │ └── icon.png │ ├── inputDialog.py │ ├── listBox.py │ ├── menubar.py │ ├── radiobutton.py │ ├── tooltip.py │ └── twoWindow.py ├── 02-QT-Designer-Examples │ ├── PyQt5-SqLite-Crud-Project-With-GUI │ │ ├── Connection.py │ │ ├── CreateTable.py │ │ ├── KullaniciArayuzu.py │ │ ├── TelefonDefteri.db │ │ ├── TelefonDefteriGUI.py │ │ ├── TelefonDefteriGUI.ui │ │ ├── __pycache__ │ │ │ ├── Connection.cpython-38.pyc │ │ │ ├── TelefonDefteriGUI.cpython-37.pyc │ │ │ └── TelefonDefteriGUI.cpython-38.pyc │ │ └── readme.md │ ├── PyQt5-SqLite-Crud-Project │ │ ├── Connection.py │ │ ├── CreateTable.py │ │ ├── DeleteData.py │ │ ├── SelectData.py │ │ ├── UpdateData.py │ │ ├── insertData.py │ │ └── myemployee.db │ ├── exp-01 │ │ ├── creating-app-v1.py │ │ ├── creating-app.py │ │ └── icon.png │ ├── exp-02 │ │ └── win-items.py │ ├── exp-03 │ │ └── win-items.py │ ├── exp-04 │ │ └── calculator.py │ ├── exp-05 │ │ ├── MainWindow.py │ │ ├── MainWindow.ui │ │ ├── __pycache__ │ │ │ └── MainWindow.cpython-38.pyc │ │ └── calculator.py │ ├── exp-06 │ │ ├── layouts.py │ │ ├── layouts_.py │ │ ├── layouts__.py │ │ ├── layouts___.py │ │ └── layouts____.py │ ├── exp-07 │ │ ├── CheckBoxForm.py │ │ ├── CheckBoxForm.ui │ │ ├── __pycache__ │ │ │ └── CheckBoxForm.cpython-38.pyc │ │ └── checkBox_.py │ ├── exp-08 │ │ ├── RadioButtonForm.py │ │ ├── RadioButtonForm.ui │ │ ├── __pycache__ │ │ │ └── RadioButtonForm.cpython-38.pyc │ │ ├── _radiobuttonForm.ui │ │ └── radioButton_.py │ ├── exp-09 │ │ ├── ComboBoxForm.py │ │ ├── ComboBoxForm.ui │ │ ├── __pycache__ │ │ │ └── ComboBoxForm.cpython-38.pyc │ │ └── comboBox_.py │ ├── exp-10 │ │ ├── MsgBoxForm.py │ │ ├── MsgBoxForm.ui │ │ ├── __pycache__ │ │ │ └── MsgBoxForm.cpython-38.pyc │ │ └── msgBox_.py │ ├── exp-11 │ │ ├── DateTimeForm.py │ │ ├── DateTimeForm.ui │ │ ├── __pycache__ │ │ │ └── DateTimeForm.cpython-38.pyc │ │ └── dateTime_.py │ ├── exp-12 │ │ ├── ListWidgetForm.py │ │ ├── ListWidgetForm.ui │ │ ├── __pycache__ │ │ │ ├── ListBoxForm.cpython-38.pyc │ │ │ └── ListWidgetForm.cpython-38.pyc │ │ └── listBox_.py │ ├── exp-13 │ │ ├── TableViewForm.ui │ │ ├── TableviewForm.py │ │ ├── __pycache__ │ │ │ └── TableviewForm.cpython-38.pyc │ │ └── tableView_.py │ └── intro │ │ ├── TelefonDefteriGUI.py │ │ ├── TelefonDefteriGUI.ui │ │ ├── Ui_TelefonDefteriGUI.py │ │ └── deneme.py ├── 03-PyQt5-SQLite-CRUD-Project │ ├── Connection.py │ ├── CreateTable.py │ ├── KullaniciArayuzu.py │ ├── LICENSE │ ├── README.md │ ├── TelefonDefteri.db │ ├── TelefonDefteriGUI.py │ ├── TelefonDefteriGUI.ui │ └── __pycache__ │ │ ├── Connection.cpython-38.pyc │ │ ├── TelefonDefteriGUI.cpython-37.pyc │ │ └── TelefonDefteriGUI.cpython-38.pyc └── 04-pyqt-haftalik-uygulamalar │ ├── altincihafta │ ├── Dial.py │ ├── Pixmap.py │ ├── Progressbar.py │ ├── Slider.py │ ├── ToolBox01.py │ ├── ToolBox02.py │ ├── autoComplete.py │ ├── images │ │ └── icon.png │ └── listBox.py │ ├── besincihafta │ ├── TabWidget.py │ ├── inputDialog.py │ ├── menubar.py │ ├── tables.py │ └── twoWindow.py │ ├── dorduncuhafta │ ├── GroupBox..py │ ├── QMessageBox.py │ ├── layout │ │ ├── QGridLayout.py │ │ ├── QVBoxLayout.py │ │ ├── layouts_.tekboyut.py │ │ ├── layouts_ciftboyut.py │ │ └── layouts_grid.py │ └── radiobutton.py │ ├── ikincihafta │ ├── ekranayazdi.py │ ├── icon.png │ └── iconuygulamasi.py │ ├── ilkhafta │ ├── Ui_deneme.py │ ├── deneme-cla.py │ ├── deneme-win.py │ ├── deneme.ui │ ├── dialog.ui │ ├── helloworld.py │ └── main.py │ ├── sekizincihafta │ ├── MainWindow.py │ ├── MainWindow.ui │ ├── Ui_MainWindow.py │ └── calculator.py │ ├── ucuncuhafta │ ├── LineEdit.py │ ├── checkbox.py │ └── combobox.py │ └── yedincihafta │ ├── PyQt5-SqLite-Crud-Project-With-GUI │ ├── Connection.py │ ├── CreateTable.py │ ├── KullaniciArayuzu.py │ ├── TelefonDefteri.db │ ├── TelefonDefteriGUI.py │ ├── TelefonDefteriGUI.ui │ ├── __pycache__ │ │ ├── Connection.cpython-38.pyc │ │ ├── TelefonDefteriGUI.cpython-313.pyc │ │ ├── TelefonDefteriGUI.cpython-37.pyc │ │ └── TelefonDefteriGUI.cpython-38.pyc │ └── readme.md │ └── PyQt5-SqLite-Crud-Project │ ├── Connection.py │ ├── CreateTable.py │ ├── DeleteData.py │ ├── SelectData.py │ ├── UpdateData.py │ ├── insertData.py │ └── myemployee.db ├── LICENSE ├── README.md └── Slides ├── 1. Bolum - Gorsel Programlama - Giris.ppt ├── 10. Bolum - Gorsel Programlama - Datetime.ppt ├── 11. Bolum - Gorsel Programlama - Listbox.ppt ├── 12. Bolum - Gorsel Programlama - Tableview.ppt ├── 13. Bolum - Gorsel Programlama - SQLite.ppt ├── 14. Bolum - Gorsel Programlama - SQLite GUI Proje.ppt ├── 2. Bolum - Gorsel Programlama - ilk uygulama.ppt ├── 3. Bolum - Gorsel Programlama - Tools.ppt ├── 4. Bolum - Gorsel Programlama - Hesap Makinesi.ppt ├── 5. Bolum - Gorsel Programlama - Layout.ppt ├── 6. Bolum - Gorsel Programlama - Checkbox ve GroupBox.ppt ├── 7. Bolum - Gorsel Programlama - Radiobutton.ppt ├── 8. Bolum - Gorsel Programlama - Combobox.ppt └── 9. Bolum - Gorsel Programlama - Msgbox.ppt /Codes/01-PyQt-GUI-Programming-Tutorial/GroupBox.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class GroupBox(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | 9 | self.setWindowTitle("GroupBox") 10 | layout = QGridLayout() 11 | self.setLayout(layout) 12 | 13 | groupbox = QGroupBox("GroupBox Example") 14 | groupbox.setCheckable(True) 15 | layout.addWidget(groupbox) 16 | 17 | vbox = QVBoxLayout() 18 | groupbox.setLayout(vbox) 19 | 20 | radiobutton = QRadioButton("RadioButton 1") 21 | vbox.addWidget(radiobutton) 22 | 23 | radiobutton = QRadioButton("RadioButton 2") 24 | vbox.addWidget(radiobutton) 25 | 26 | radiobutton = QRadioButton("RadioButton 3") 27 | vbox.addWidget(radiobutton) 28 | 29 | radiobutton = QRadioButton("RadioButton 4") 30 | vbox.addWidget(radiobutton) 31 | 32 | 33 | app = QApplication(sys.argv) 34 | screen = GroupBox() 35 | screen.show() 36 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/Progressbar.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtCore import QTimer 3 | from PyQt5.QtWidgets import QApplication, QMainWindow, QProgressBar 4 | from PyQt5.QtCore import Qt 5 | 6 | class Example(QMainWindow): 7 | 8 | def __init__(self): 9 | super().__init__() 10 | 11 | self.pbar = QProgressBar(self) 12 | self.pbar.setGeometry(30, 40, 200, 25) 13 | self.pbar.setValue(50) 14 | 15 | self.setWindowTitle("QT Progressbar Example") 16 | self.setGeometry(32,32,320,200) 17 | self.show() 18 | 19 | self.timer = QTimer() 20 | self.timer.timeout.connect(self.handleTimer) 21 | self.timer.start(1000) 22 | 23 | def handleTimer(self): 24 | value = self.pbar.value() 25 | if value < 100: 26 | value = value + 1 27 | self.pbar.setValue(value) 28 | else: 29 | self.timer.stop() 30 | 31 | 32 | if __name__ == '__main__': 33 | app = QApplication(sys.argv) 34 | ex = Example() 35 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QCheckBox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QCheckBox 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | cb = QCheckBox('Movie', self) 10 | cb.move(20, 20) 11 | 12 | cb2 = QCheckBox('Music', self) 13 | cb2.move(20, 40) 14 | cb2.toggle() 15 | 16 | self.setGeometry(50,50,320,200) 17 | self.setWindowTitle("Checkbox Example") 18 | self.show() 19 | 20 | if __name__ == '__main__': 21 | app = QApplication(sys.argv) 22 | ex = Example() 23 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QDial.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | self.dial = QDial() 10 | self.dial.setMinimum(0) 11 | self.dial.setMaximum(100) 12 | self.dial.setValue(40) 13 | self.dial.valueChanged.connect(self.sliderMoved) 14 | layout.addWidget(self.dial) 15 | 16 | def sliderMoved(self): 17 | print("Dial value = %i" % (self.dial.value())) 18 | 19 | app = QApplication(sys.argv) 20 | screen = Window() 21 | screen.show() 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QLineEdit.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | self.lineEntry = QLineEdit(self) 10 | self.lineEntry.move(16,16) 11 | self.lineEntry.resize(200,40) 12 | 13 | self.qlabel = QLabel(self) 14 | self.qlabel.move(16,64) 15 | 16 | self.lineEntry.textChanged.connect(self.onChanged) 17 | 18 | self.setGeometry(50,50,320,200) 19 | self.setWindowTitle("QLineEdit Example") 20 | self.show() 21 | 22 | def onChanged(self, text): 23 | self.qlabel.setText(text) 24 | self.qlabel.adjustSize() 25 | 26 | if __name__ == '__main__': 27 | app = QApplication(sys.argv) 28 | ex = Example() 29 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QMessageBox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QWidget() 9 | button1 = QPushButton(win) 10 | button1.setText("Show dialog!") 11 | button1.move(50,50) 12 | button1.clicked.connect(showDialog) 13 | win.setWindowTitle("Click button") 14 | win.show() 15 | sys.exit(app.exec_()) 16 | 17 | def showDialog(): 18 | msgBox = QMessageBox() 19 | msgBox.setIcon(QMessageBox.Information) 20 | msgBox.setText("Message box pop up window") 21 | msgBox.setWindowTitle("QMessageBox Example") 22 | msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) 23 | msgBox.buttonClicked.connect(msgButtonClick) 24 | 25 | returnValue = msgBox.exec() 26 | if returnValue == QMessageBox.Ok: 27 | print('OK clicked') 28 | 29 | def msgButtonClick(i): 30 | print("Button clicked is:",i.text()) 31 | 32 | if __name__ == '__main__': 33 | window() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QPixmap.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget 3 | from PyQt5.QtGui import QPixmap 4 | 5 | class Example(QWidget): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | 10 | self.im = QPixmap("./images/icon.png") 11 | self.label = QLabel() 12 | self.label.setPixmap(self.im) 13 | 14 | self.grid = QGridLayout() 15 | self.grid.addWidget(self.label,1,1) 16 | self.setLayout(self.grid) 17 | 18 | self.setGeometry(50,50,320,200) 19 | self.setWindowTitle("PyQT show image") 20 | self.show() 21 | 22 | if __name__ == '__main__': 23 | app = QApplication(sys.argv) 24 | ex = Example() 25 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QSlider.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QSlider 3 | from PyQt5.QtCore import Qt 4 | 5 | class Example(QMainWindow): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | 10 | mySlider = QSlider(Qt.Horizontal, self) 11 | mySlider.setGeometry(30, 40, 200, 30) 12 | mySlider.valueChanged[int].connect(self.changeValue) 13 | 14 | self.setGeometry(50,50,320,200) 15 | self.setWindowTitle("Checkbox Example") 16 | self.show() 17 | 18 | def changeValue(self, value): 19 | print(value) 20 | 21 | if __name__ == '__main__': 22 | app = QApplication(sys.argv) 23 | ex = Example() 24 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QToolBox01.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # Add toolbar and items 12 | toolbox = QToolBox() 13 | layout.addWidget(toolbox, 0, 0) 14 | label = QLabel() 15 | toolbox.addItem(label, "Students") 16 | label = QLabel() 17 | toolbox.addItem(label, "Teachers") 18 | label = QLabel() 19 | toolbox.addItem(label, "Directors") 20 | 21 | app = QApplication(sys.argv) 22 | screen = Window() 23 | screen.show() 24 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QToolBox02.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # Add toolbar and items 12 | toolbox = QToolBox() 13 | layout.addWidget(toolbox, 0, 0) 14 | label = QLabel() 15 | toolbox.addItem(label, "Students") 16 | label = QLabel() 17 | toolbox.addItem(label, "Teachers") 18 | label = QLabel() 19 | toolbox.addItem(label, "Directors") 20 | 21 | # show number of items 22 | print(toolbox.count()) 23 | 24 | # disable tab 25 | toolbox.setItemEnabled(0, False) 26 | 27 | # mouseover tooltip 28 | toolbox.setItemToolTip(0, "This is a tooltip") 29 | 30 | # tests if items are enabled 31 | print(toolbox.isItemEnabled(0)) 32 | print(toolbox.isItemEnabled(1)) 33 | 34 | # insert item 35 | item = QLabel() 36 | toolbox.insertItem(1, item, "Python") 37 | 38 | app = QApplication(sys.argv) 39 | screen = Window() 40 | screen.show() 41 | sys.exit(app.exec_()) 42 | 43 | 44 | #Methods 45 | #The QToolBox has many methods that can be used, you’ve seen .addItem() before but there are many more. 46 | 47 | #addItem() 48 | #count() 49 | #currentIndex() 50 | #insertItem() 51 | #itemToolTip() 52 | #itemText() 53 | #itemIcon() 54 | #isItemEnabled() 55 | #removeItem() 56 | #setItemEnabled() 57 | #setItemIcon() 58 | #setItemText() 59 | #setItemToolTip() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/QVboxLayout .py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout 2 | 3 | app = QApplication([]) 4 | window = QWidget() 5 | layout = QVBoxLayout() 6 | layout.addWidget(QPushButton('1')) 7 | layout.addWidget(QPushButton('2')) 8 | layout.addWidget(QPushButton('3')) 9 | 10 | window.setLayout(layout) 11 | window.show() 12 | app.exec_() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/TabWidget.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtWidgets import * 3 | import sys 4 | 5 | class Window(QWidget): 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | label1 = QLabel("Widget in Tab 1.") 11 | label2 = QLabel("Widget in Tab 2.") 12 | tabwidget = QTabWidget() 13 | tabwidget.addTab(label1, "Tab 1") 14 | tabwidget.addTab(label2, "Tab 2") 15 | layout.addWidget(tabwidget, 0, 0) 16 | 17 | app = QApplication(sys.argv) 18 | screen = Window() 19 | screen.show() 20 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/Tables.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QAction, QTableWidget,QTableWidgetItem,QVBoxLayout 2 | from PyQt5.QtGui import QIcon 3 | from PyQt5.QtCore import pyqtSlot 4 | import sys 5 | 6 | data = {'col1':['1','2','3','4'], 7 | 'col2':['1','2','1','3'], 8 | 'col3':['1','1','2','1']} 9 | 10 | class TableView(QTableWidget): 11 | def __init__(self, data, *args): 12 | QTableWidget.__init__(self, *args) 13 | self.data = data 14 | self.setData() 15 | self.resizeColumnsToContents() 16 | self.resizeRowsToContents() 17 | 18 | def setData(self): 19 | horHeaders = [] 20 | for n, key in enumerate(sorted(self.data.keys())): 21 | horHeaders.append(key) 22 | for m, item in enumerate(self.data[key]): 23 | newitem = QTableWidgetItem(item) 24 | self.setItem(m, n, newitem) 25 | self.setHorizontalHeaderLabels(horHeaders) 26 | 27 | def main(args): 28 | app = QApplication(args) 29 | table = TableView(data, 4, 3) 30 | table.show() 31 | sys.exit(app.exec_()) 32 | 33 | if __name__=="__main__": 34 | main(sys.argv) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/Toolbar.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # Create pyqt toolbar 12 | toolBar = QToolBar() 13 | layout.addWidget(toolBar) 14 | 15 | # Add buttons to toolbar 16 | toolButton = QToolButton() 17 | toolButton.setText("Apple") 18 | toolButton.setCheckable(True) 19 | toolButton.setAutoExclusive(True) 20 | toolBar.addWidget(toolButton) 21 | toolButton = QToolButton() 22 | toolButton.setText("Orange") 23 | toolButton.setCheckable(True) 24 | toolButton.setAutoExclusive(True) 25 | toolBar.addWidget(toolButton) 26 | 27 | # Add textfield to window 28 | tbox = QPlainTextEdit() 29 | layout.addWidget(tbox) 30 | 31 | app = QApplication(sys.argv) 32 | screen = Window() 33 | screen.show() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/autoComplete.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | 10 | # auto complete options 11 | names = ["Apple", "Alps", "Berry", "Cherry" ] 12 | completer = QCompleter(names) 13 | 14 | # create line edit and add auto complete 15 | self.lineedit = QLineEdit() 16 | self.lineedit.setCompleter(completer) 17 | layout.addWidget(self.lineedit, 0, 0) 18 | 19 | app = QApplication(sys.argv) 20 | screen = Window() 21 | screen.show() 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/buttons.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | widget = QWidget() 9 | 10 | button1 = QPushButton(widget) 11 | button1.setText("Button1") 12 | button1.move(64,32) 13 | button1.clicked.connect(button1_clicked) 14 | 15 | button2 = QPushButton(widget) 16 | button2.setText("Button2") 17 | button2.move(64,64) 18 | button2.clicked.connect(button2_clicked) 19 | 20 | widget.setGeometry(50,50,320,200) 21 | widget.setWindowTitle("PyQt5 Button Click Example") 22 | widget.show() 23 | sys.exit(app.exec_()) 24 | 25 | 26 | def button1_clicked(): 27 | print("Button 1 clicked") 28 | 29 | def button2_clicked(): 30 | print("Button 2 clicked") 31 | 32 | if __name__ == '__main__': 33 | window() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/combobox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QComboBox, QPushButton 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | combo = QComboBox(self) 10 | combo.addItem("Apple") 11 | combo.addItem("Pear") 12 | combo.addItem("Lemon") 13 | 14 | combo.move(50, 50) 15 | 16 | self.qlabel = QLabel(self) 17 | self.qlabel.move(50,16) 18 | 19 | combo.activated[str].connect(self.onChanged) 20 | 21 | self.setGeometry(50,50,320,200) 22 | self.setWindowTitle("QLineEdit Example") 23 | self.show() 24 | 25 | def onChanged(self, text): 26 | self.qlabel.setText(text) 27 | self.qlabel.adjustSize() 28 | 29 | if __name__ == '__main__': 30 | app = QApplication(sys.argv) 31 | ex = Example() 32 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/grid.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QWidget() 9 | grid = QGridLayout() 10 | 11 | for i in range(0,5): 12 | for j in range(0,5): 13 | grid.addWidget(QPushButton(str(i)+str(j)),i,j) 14 | 15 | win.setLayout(grid) 16 | win.setWindowTitle("PyQt Grid Example") 17 | win.setGeometry(50,50,200,200) 18 | win.show() 19 | sys.exit(app.exec_()) 20 | 21 | if __name__ == '__main__': 22 | window() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/helloWorld.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QLabel 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | widget = QWidget() 9 | 10 | textLabel = QLabel(widget) 11 | textLabel.setText("Hello World!") 12 | textLabel.move(110,85) 13 | 14 | widget.setGeometry(50,50,320,200) 15 | widget.setWindowTitle("PyQt5 Example") 16 | widget.show() 17 | sys.exit(app.exec_()) 18 | 19 | if __name__ == '__main__': 20 | window() -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/01-PyQt-GUI-Programming-Tutorial/images/icon.png -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/inputDialog.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import (QWidget, QPushButton, QLineEdit, QInputDialog, QApplication, QLabel) 2 | import sys 3 | 4 | class Example(QWidget): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | self.initUI() 9 | 10 | def initUI(self): 11 | # Add button 12 | self.btn = QPushButton('Show Input Dialog', self) 13 | self.btn.move(30, 20) 14 | self.btn.clicked.connect(self.showDialog) 15 | 16 | # Add label 17 | self.le = QLabel(self) 18 | self.le.move(30, 62) 19 | self.le.resize(400,22) 20 | 21 | self.setGeometry(300, 300, 290, 150) 22 | self.setWindowTitle('Input dialog') 23 | self.show() 24 | 25 | 26 | def showDialog(self): 27 | text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter text:') 28 | if ok: 29 | self.le.setText(str(text)) 30 | 31 | if __name__ == '__main__': 32 | app = QApplication(sys.argv) 33 | ex = Example() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/listBox.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | self.listwidget = QListWidget() 10 | self.listwidget.insertItem(0, "Red") 11 | self.listwidget.insertItem(1, "Orange") 12 | self.listwidget.insertItem(2, "Blue") 13 | self.listwidget.insertItem(3, "White") 14 | self.listwidget.insertItem(4, "Green") 15 | self.listwidget.clicked.connect(self.clicked) 16 | layout.addWidget(self.listwidget) 17 | 18 | def clicked(self, qmodelindex): 19 | item = self.listwidget.currentItem() 20 | print(item.text()) 21 | 22 | app = QApplication(sys.argv) 23 | screen = Window() 24 | screen.show() 25 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/menubar.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtWidgets import * 3 | import sys 4 | 5 | class Window(QWidget): 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # create menu 12 | menubar = QMenuBar() 13 | layout.addWidget(menubar, 0, 0) 14 | actionFile = menubar.addMenu("File") 15 | actionFile.addAction("New") 16 | actionFile.addAction("Open") 17 | actionFile.addAction("Save") 18 | actionFile.addSeparator() 19 | actionFile.addAction("Quit") 20 | menubar.addMenu("Edit") 21 | menubar.addMenu("View") 22 | menubar.addMenu("Help") 23 | 24 | # add textbox 25 | tbox = QPlainTextEdit() 26 | layout.addWidget(tbox, 1, 0) 27 | 28 | 29 | app = QApplication(sys.argv) 30 | screen = Window() 31 | screen.show() 32 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/radiobutton.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | 10 | radiobutton = QRadioButton("Australia") 11 | radiobutton.setChecked(True) 12 | radiobutton.country = "Australia" 13 | radiobutton.toggled.connect(self.onClicked) 14 | layout.addWidget(radiobutton, 0, 0) 15 | 16 | radiobutton = QRadioButton("China") 17 | radiobutton.country = "China" 18 | radiobutton.toggled.connect(self.onClicked) 19 | layout.addWidget(radiobutton, 0, 1) 20 | 21 | radiobutton = QRadioButton("Japan") 22 | radiobutton.country = "Japan" 23 | radiobutton.toggled.connect(self.onClicked) 24 | layout.addWidget(radiobutton, 0, 2) 25 | 26 | def onClicked(self): 27 | radioButton = self.sender() 28 | if radioButton.isChecked(): 29 | print("Country is %s" % (radioButton.country)) 30 | 31 | app = QApplication(sys.argv) 32 | screen = Window() 33 | screen.show() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/tooltip.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | button = QPushButton("Button") 12 | button.setToolTip("This is a text") 13 | layout.addWidget(button, 0, 0) 14 | 15 | button = QPushButton("Button") 16 | button.setToolTip("HTML can be shown too..") 17 | layout.addWidget(button, 1, 0) 18 | 19 | app = QApplication(sys.argv) 20 | screen = Window() 21 | screen.show() 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/01-PyQt-GUI-Programming-Tutorial/twoWindow.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtGui 3 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton, 4 | QToolTip, QMessageBox, QLabel) 5 | 6 | class Window2(QMainWindow): # <=== 7 | def __init__(self): 8 | super().__init__() 9 | self.setWindowTitle("Window22222") 10 | 11 | class Window(QMainWindow): 12 | def __init__(self): 13 | super().__init__() 14 | 15 | self.title = "First Window" 16 | self.top = 100 17 | self.left = 100 18 | self.width = 680 19 | self.height = 500 20 | 21 | self.pushButton = QPushButton("Start", self) 22 | self.pushButton.move(275, 200) 23 | self.pushButton.setToolTip("

Start the Session

") 24 | 25 | self.pushButton.clicked.connect(self.window2) # <=== 26 | 27 | self.main_window() 28 | 29 | def main_window(self): 30 | self.label = QLabel("Manager", self) 31 | self.label.move(285, 175) 32 | self.setWindowTitle(self.title) 33 | self.setGeometry(self.top, self.left, self.width, self.height) 34 | self.show() 35 | 36 | def window2(self): # <=== 37 | self.w = Window2() 38 | self.w.show() 39 | self.hide() 40 | 41 | if __name__ == "__main__": 42 | app = QApplication(sys.argv) 43 | window = Window() 44 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/Connection.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | print("Database created") 7 | except: 8 | print("failed to create database") 9 | finally: 10 | db.close() 11 | 12 | if __name__ == "__main__": 13 | main() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/CreateTable.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | cur = db.cursor() 7 | tablequery = "CREATE TABLE Kullanicilar (id INT, isim TEXT, soyisim TEXT, sehir TEXT, telefon TEXT, email TEXT)" 8 | 9 | cur.execute(tablequery) 10 | print("Table Created Succesfully") 11 | 12 | except sql.Error as e: 13 | print("There is a table or an error has occurred") 14 | 15 | finally: 16 | db.close() 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteri.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteri.db -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteriGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'TelefonDefteriGUI.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(910, 723) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnKaydet = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnKaydet.setGeometry(QtCore.QRect(560, 20, 211, 41)) 21 | self.btnKaydet.setObjectName("btnKaydet") 22 | self.btnSil = QtWidgets.QPushButton(self.centralwidget) 23 | self.btnSil.setGeometry(QtCore.QRect(560, 70, 211, 41)) 24 | self.btnSil.setObjectName("btnSil") 25 | self.btnGuncelle = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGuncelle.setGeometry(QtCore.QRect(560, 120, 211, 41)) 27 | self.btnGuncelle.setObjectName("btnGuncelle") 28 | self.btnListele = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnListele.setGeometry(QtCore.QRect(560, 170, 211, 41)) 30 | self.btnListele.setObjectName("btnListele") 31 | self.txtID = QtWidgets.QLineEdit(self.centralwidget) 32 | self.txtID.setGeometry(QtCore.QRect(220, 20, 311, 41)) 33 | self.txtID.setObjectName("txtID") 34 | self.txtIsim = QtWidgets.QLineEdit(self.centralwidget) 35 | self.txtIsim.setGeometry(QtCore.QRect(220, 70, 311, 41)) 36 | self.txtIsim.setObjectName("txtIsim") 37 | self.txtSoyisim = QtWidgets.QLineEdit(self.centralwidget) 38 | self.txtSoyisim.setGeometry(QtCore.QRect(220, 120, 311, 41)) 39 | self.txtSoyisim.setObjectName("txtSoyisim") 40 | self.txtSehir = QtWidgets.QLineEdit(self.centralwidget) 41 | self.txtSehir.setGeometry(QtCore.QRect(220, 170, 311, 41)) 42 | self.txtSehir.setObjectName("txtSehir") 43 | self.txtTelefon = QtWidgets.QLineEdit(self.centralwidget) 44 | self.txtTelefon.setGeometry(QtCore.QRect(220, 220, 311, 41)) 45 | self.txtTelefon.setObjectName("txtTelefon") 46 | self.txtEmail = QtWidgets.QLineEdit(self.centralwidget) 47 | self.txtEmail.setGeometry(QtCore.QRect(220, 270, 311, 41)) 48 | self.txtEmail.setObjectName("txtEmail") 49 | self.lblID = QtWidgets.QLabel(self.centralwidget) 50 | self.lblID.setGeometry(QtCore.QRect(10, 20, 201, 41)) 51 | self.lblID.setObjectName("lblID") 52 | self.lblISIM = QtWidgets.QLabel(self.centralwidget) 53 | self.lblISIM.setGeometry(QtCore.QRect(10, 70, 201, 41)) 54 | self.lblISIM.setObjectName("lblISIM") 55 | self.lblSoyisim = QtWidgets.QLabel(self.centralwidget) 56 | self.lblSoyisim.setGeometry(QtCore.QRect(10, 120, 201, 41)) 57 | self.lblSoyisim.setObjectName("lblSoyisim") 58 | self.lblSehir = QtWidgets.QLabel(self.centralwidget) 59 | self.lblSehir.setGeometry(QtCore.QRect(10, 170, 201, 41)) 60 | self.lblSehir.setObjectName("lblSehir") 61 | self.lblTelefon = QtWidgets.QLabel(self.centralwidget) 62 | self.lblTelefon.setGeometry(QtCore.QRect(10, 220, 201, 41)) 63 | self.lblTelefon.setObjectName("lblTelefon") 64 | self.lblEmail = QtWidgets.QLabel(self.centralwidget) 65 | self.lblEmail.setGeometry(QtCore.QRect(10, 270, 201, 41)) 66 | self.lblEmail.setObjectName("lblEmail") 67 | self.tblListele = QtWidgets.QTableWidget(self.centralwidget) 68 | self.tblListele.setGeometry(QtCore.QRect(10, 330, 891, 341)) 69 | self.tblListele.setObjectName("tblListele") 70 | self.tblListele.setColumnCount(0) 71 | self.tblListele.setRowCount(0) 72 | MainWindow.setCentralWidget(self.centralwidget) 73 | self.menubar = QtWidgets.QMenuBar(MainWindow) 74 | self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 22)) 75 | self.menubar.setObjectName("menubar") 76 | MainWindow.setMenuBar(self.menubar) 77 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 78 | self.statusbar.setObjectName("statusbar") 79 | MainWindow.setStatusBar(self.statusbar) 80 | 81 | self.retranslateUi(MainWindow) 82 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 83 | 84 | def retranslateUi(self, MainWindow): 85 | _translate = QtCore.QCoreApplication.translate 86 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 87 | self.btnKaydet.setText(_translate("MainWindow", "KAYDET")) 88 | self.btnSil.setText(_translate("MainWindow", "SIL")) 89 | self.btnGuncelle.setText(_translate("MainWindow", "GUNCELLE")) 90 | self.btnListele.setText(_translate("MainWindow", "LISTELE")) 91 | self.lblID.setText(_translate("MainWindow", "ID")) 92 | self.lblISIM.setText(_translate("MainWindow", "ISIM")) 93 | self.lblSoyisim.setText(_translate("MainWindow", "SOYISIM")) 94 | self.lblSehir.setText(_translate("MainWindow", "SEHIR")) 95 | self.lblTelefon.setText(_translate("MainWindow", "TELEFON")) 96 | self.lblEmail.setText(_translate("MainWindow", "EMAIL")) 97 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/Connection.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/Connection.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-37.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project-With-GUI/readme.md: -------------------------------------------------------------------------------- 1 | # PyQt5-SqLite-Crud-Project-With-GUI 2 | 3 | For the visual programming course, it was connected to the database with SQLite using the PyQT5 user interface and CRUD operations were performed. 4 | 5 | ![image](https://user-images.githubusercontent.com/5441882/94076479-df211400-fe05-11ea-82a8-8ef79ddcb9e9.png) 6 | 7 | ![image](https://user-images.githubusercontent.com/5441882/94076101-12af6e80-fe05-11ea-9cb7-05a1361d89ce.png) 8 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/Connection.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | def main(): 4 | try: 5 | db = lit.connect('myemployee.db') 6 | print("Database created") 7 | except: 8 | print("failed to create database") 9 | finally: 10 | db.close() 11 | 12 | if __name__ == "__main__": 13 | main() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/CreateTable.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | def main(): 4 | try: 5 | db = lit.connect('myemployee.db') 6 | cur = db.cursor() 7 | tablequery = "CREATE TABLE users (id INT, name TEXT, email TEXT)" 8 | 9 | cur.execute(tablequery) 10 | print("Table Created Succesfully") 11 | 12 | except lit.Error as e: 13 | print("Unable To Create Table") 14 | 15 | finally: 16 | db.close() 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/DeleteData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | 7 | newname = "updated name" 8 | user_id = 1 9 | 10 | cur = db.cursor() 11 | cur.execute('DELETE FROM users WHERE id = ? ', (user_id,) ) 12 | db.commit() 13 | print("Data Deleted Successfully") 14 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/SelectData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | cur = db.cursor() 7 | selectquery = "SELECT * FROM users" 8 | cur.execute(selectquery) 9 | 10 | rows = cur.fetchall() 11 | 12 | for data in rows: 13 | print(data) 14 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/UpdateData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | 7 | newname = "updated name" 8 | user_id = 1 9 | 10 | cur = db.cursor() 11 | cur.execute('UPDATE users SET name = ? WHERE id = ?', (newname, user_id)) 12 | db.commit() 13 | print("Data Updated Successfully") 14 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/insertData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | myuser = ( 3 | 4 | (1, 'Parwiz', 'par@gmail.com'), 5 | (2, 'John', 'john@gmail.com'), 6 | (3, 'Bob', 'bob@gmail.com'), 7 | (4, 'Tom', 'tom@gmail.com'), 8 | 9 | ) 10 | db = lit.connect('myemployee.db') 11 | 12 | with db: 13 | cur = db.cursor() 14 | cur.executemany('INSERT INTO users VALUES (?,?,?)', myuser) 15 | 16 | print("Data Inserted Successfully") -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/myemployee.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/PyQt5-SqLite-Crud-Project/myemployee.db -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-01/creating-app-v1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | #komut satirini kullanacagimiz icin sys kullaniliyor 4 | #qtwidgets ile qt designer'in toollarini aktiflestiriyoruz 5 | from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip 6 | from PyQt5.QtGui import QIcon 7 | 8 | def window(): #pencere olusturuyoruz ve nesnelerle baglantisini yapiyoruz. 9 | # app = QtWidgets.QApplication egerki from PyQt5.QtWidgets import QApplication, QMainWindow 10 | # yazilmayacaksa bu kod yazilabilir. yazilacaksa asagidaki gibi kullanilir 11 | app = QApplication(sys.argv) 12 | win = QMainWindow() #pencere nesnesi aktif hale getiriliyor ve bir degiskene aktariliyor 13 | 14 | win.setWindowTitle('Ilk Uygulama') #pencereye title yazdiriliyor. 15 | win.setGeometry(200,200,500,500) #pencerenin yatay ve dikeyde gorulen pixel boyutlariyla pencerenin yatay ve dikeydeki boyutlari 16 | win.setWindowIcon(QIcon('icon.png')) #icon icin qicon kutuphanesinden qtgui eklentisi kullanilmaktadir. 17 | win.setToolTip('Tooltip Mesaji') #tooltip mesaji yazilabilmektedir. bunun icin qtooltip kutuphanesi kullanilmaktadir. 18 | 19 | 20 | 21 | win.show() #pencere gosteriliyor 22 | sys.exit(app.exec_()) #pencere kapatmak icin x iconu ekleniyor 23 | 24 | 25 | window() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-01/creating-app.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | #komut satirini kullanacagimiz icin sys kullaniliyor 4 | #qtwidgets ile qt designer'in toollarini aktiflestiriyoruz 5 | from PyQt5.QtWidgets import QApplication, QMainWindow 6 | 7 | def window(): #pencere olusturuyoruz ve nesnelerle baglantisini yapiyoruz. 8 | # app = QtWidgets.QApplication egerki from PyQt5.QtWidgets import QApplication, QMainWindow 9 | # yazilmayacaksa bu kod yazilabilir. yazilacaksa asagidaki gibi kullanilir 10 | app = QApplication(sys.argv) 11 | win = QMainWindow() #pencere nesnesi aktif hale getiriliyor ve bir degiskene aktariliyor 12 | 13 | win.show() #pencere gosteriliyor 14 | sys.exit(app.exec_()) #pencere kapatmak icin x iconu ekleniyor 15 | 16 | 17 | window() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-01/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-01/icon.png -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-02/win-items.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | #komut satirini kullanacagimiz icin sys kullaniliyor 4 | #qtwidgets ile qt designer'in toollarini aktiflestiriyoruz 5 | from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip 6 | from PyQt5.QtGui import QIcon 7 | 8 | 9 | def window(): #pencere olusturuyoruz ve nesnelerle baglantisini yapiyoruz. 10 | # app = QtWidgets.QApplication egerki from PyQt5.QtWidgets import QApplication, QMainWindow 11 | # yazilmayacaksa bu kod yazilabilir. yazilacaksa asagidaki gibi kullanilir 12 | app = QApplication(sys.argv) 13 | win = QMainWindow() #pencere nesnesi aktif hale getiriliyor ve bir degiskene aktariliyor 14 | 15 | 16 | 17 | win.setWindowTitle('Ilk Uygulama') #pencereye title yazdiriliyor. 18 | win.setGeometry(200,200,500,500) #pencerenin yatay ve dikeyde gorulen pixel boyutlariyla pencerenin yatay ve dikeydeki boyutlari 19 | win.setWindowIcon(QIcon('icon.png')) #icon icin qicon kutuphanesinden qtgui eklentisi kullanilmaktadir. 20 | win.setToolTip('Tooltip Mesaji') #tooltip mesaji yazilabilmektedir. bunun icin qtooltip kutuphanesi kullanilmaktadir. 21 | 22 | lbl_isim = QtWidgets.QLabel(win) 23 | lbl_isim.setText('Isminiz : ') 24 | lbl_isim.move(50,30) 25 | 26 | lbl_soyisim = QtWidgets.QLabel(win) 27 | lbl_soyisim.setText('Soyisminiz : ') 28 | lbl_soyisim.move(50,70) 29 | 30 | txt_isim = QtWidgets.QLineEdit(win) 31 | txt_isim.move(250, 30) 32 | 33 | txt_soyisim = QtWidgets.QLineEdit(win) 34 | txt_soyisim.move(250, 70) 35 | 36 | def clicked(self): 37 | print(txt_isim.text() + ' ' + txt_soyisim.text() + ' kisisi sisteme kaydedilmistir' ) 38 | 39 | btn_kaydet = QtWidgets.QPushButton(win) 40 | btn_kaydet.move(250, 110) 41 | btn_kaydet.setText('Kaydet') 42 | 43 | btn_kaydet.clicked.connect(clicked) 44 | 45 | 46 | 47 | 48 | win.show() #pencere gosteriliyor 49 | sys.exit(app.exec_()) #pencere kapatmak icin x iconu ekleniyor 50 | 51 | 52 | window() 53 | 54 | 55 | 56 | # QLabel 57 | # QComboBox 58 | # QCheckBox 59 | # QRadioButton 60 | # QPushButton 61 | # QTableWidget 62 | # QLineEdit 63 | # QSlider 64 | # QProgressBar -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-03/win-items.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip 4 | from PyQt5.QtGui import QIcon 5 | 6 | 7 | class MyWindow(QMainWindow): 8 | def __init__(self): 9 | super(MyWindow, self).__init__() 10 | 11 | self.setWindowTitle('Ilk Uygulama') 12 | self.setGeometry(200,200,500,500) 13 | self.setWindowIcon(QIcon('icon.png')) 14 | self.setToolTip('Tooltip Mesaji') 15 | self.initUI() 16 | 17 | def initUI(self): 18 | self.lbl_isim = QtWidgets.QLabel(self) 19 | self.lbl_isim.setText('Isminiz : ') 20 | self.lbl_isim.move(50,30) 21 | 22 | self.lbl_soyisim = QtWidgets.QLabel(self) 23 | self.lbl_soyisim.setText('Soyisminiz : ') 24 | self.lbl_soyisim.move(50,70) 25 | 26 | self.lbl_sonuc = QtWidgets.QLabel(self) 27 | self.lbl_sonuc.move(150,150) 28 | self.lbl_sonuc.setText('Sonuc') 29 | self.lbl_sonuc.resize(300,50) 30 | 31 | self.txt_isim = QtWidgets.QLineEdit(self) 32 | self.txt_isim.move(250, 30) 33 | self.txt_isim.resize(200,32) 34 | 35 | self.txt_soyisim = QtWidgets.QLineEdit(self) 36 | self.txt_soyisim.move(250, 70) 37 | self.txt_soyisim.resize(200,32) 38 | 39 | self.btn_kaydet = QtWidgets.QPushButton(self) 40 | self.btn_kaydet.move(250, 110) 41 | self.btn_kaydet.setText('Kaydet') 42 | 43 | self.btn_kaydet.clicked.connect(self.clicked) 44 | 45 | def clicked(self): 46 | self.lbl_sonuc.setText(self.txt_isim.text() + ' ' + self.txt_soyisim.text() + ' kisisi sisteme kaydedilmistir') 47 | 48 | 49 | def window(): 50 | app = QApplication(sys.argv) 51 | win = MyWindow() 52 | 53 | win.show() 54 | sys.exit(app.exec_()) 55 | 56 | window() 57 | 58 | # QLabel 59 | # QComboBox 60 | # QCheckBox 61 | # QRadioButton 62 | # QPushButton 63 | # QTableWidget 64 | # QLineEdit 65 | # QSlider 66 | # QProgressBar -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-04/calculator.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QMainWindow 4 | 5 | class MainForm(QMainWindow): 6 | def __init__(self): 7 | super(MainForm, self).__init__() 8 | 9 | self.setWindowTitle('Hesap makinesi') 10 | self.setGeometry(200,200,500,500) 11 | self.initUI() 12 | 13 | def initUI(self): 14 | self.lbl_sayi1 = QtWidgets.QLabel(self) 15 | self.lbl_sayi1.setText('Birinci Sayiyi Giriniz : ') 16 | self.lbl_sayi1.move(50,30) 17 | self.lbl_sayi1.resize(200,32) 18 | 19 | self.txt_sayi1 = QtWidgets.QLineEdit(self) 20 | self.txt_sayi1.move(250,30) 21 | self.txt_sayi1.resize(200,32) 22 | 23 | self.lbl_sayi2 = QtWidgets.QLabel(self) 24 | self.lbl_sayi2.setText('Ikinci Sayiyi Giriniz : ') 25 | self.lbl_sayi2.move(50,80) 26 | self.lbl_sayi2.resize(200,32) 27 | 28 | self.txt_sayi2 = QtWidgets.QLineEdit(self) 29 | self.txt_sayi2.move(250,80) 30 | self.txt_sayi2.resize(200,32) 31 | 32 | self.btn_topla = QtWidgets.QPushButton(self) 33 | self.btn_topla.setText('Topla') 34 | self.btn_topla.move(150, 130) 35 | #self.btn_topla.clicked.connect(self.toplama) 36 | self.btn_topla.clicked.connect(self.hesapla) 37 | 38 | self.btn_cikar = QtWidgets.QPushButton(self) 39 | self.btn_cikar.setText('Cikar') 40 | self.btn_cikar.move(150, 170) 41 | #self.btn_cikar.clicked.connect(self.cikarma) 42 | self.btn_cikar.clicked.connect(self.hesapla) 43 | 44 | self.btn_carpma = QtWidgets.QPushButton(self) 45 | self.btn_carpma.setText('Carpma') 46 | self.btn_carpma.move(150, 210) 47 | #self.btn_carpma.clicked.connect(self.carpma) 48 | self.btn_carpma.clicked.connect(self.hesapla) 49 | 50 | self.btn_bolme = QtWidgets.QPushButton(self) 51 | self.btn_bolme.setText('Bolme') 52 | self.btn_bolme.move(150, 250) 53 | #self.btn_bolme.clicked.connect(self.bolme) 54 | self.btn_bolme.clicked.connect(self.hesapla) 55 | 56 | self.lbl_sonuc = QtWidgets.QLabel(self) 57 | self.lbl_sonuc.setText('Sonuc : ') 58 | self.lbl_sonuc.resize(300,32) 59 | self.lbl_sonuc.move(150,290) 60 | 61 | def toplama(self): 62 | result = int(self.txt_sayi1.text()) + int(self.txt_sayi2.text()) 63 | self.lbl_sonuc.setText('Sonuc : ' + str(result) ) 64 | 65 | def cikarma(self): 66 | result = int(self.txt_sayi1.text()) - int(self.txt_sayi2.text()) 67 | self.lbl_sonuc.setText('Sonuc : ' + str(result) ) 68 | 69 | def carpma(self): 70 | result = int(self.txt_sayi1.text()) * int(self.txt_sayi2.text()) 71 | self.lbl_sonuc.setText('Sonuc : ' + str(result) ) 72 | 73 | def bolme(self): 74 | result = int(self.txt_sayi1.text()) / int(self.txt_sayi2.text()) 75 | self.lbl_sonuc.setText('Sonuc : ' + str(result) ) 76 | 77 | def hesapla(self): 78 | sender = self.sender().text() 79 | #print(sender.text()) 80 | result=0 81 | 82 | if sender=='Topla': 83 | result = int(self.txt_sayi1.text()) + int(self.txt_sayi2.text()) 84 | elif sender=='Cikar': 85 | result = int(self.txt_sayi1.text()) - int(self.txt_sayi2.text()) 86 | elif sender=='Carpma': 87 | result = int(self.txt_sayi1.text()) * int(self.txt_sayi2.text()) 88 | elif sender=='Bolme': 89 | result = int(self.txt_sayi1.text()) / int(self.txt_sayi2.text()) 90 | 91 | self.lbl_sonuc.setText('Sonuc : ' + str(result) ) 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | def app(): 101 | app = QApplication(sys.argv) 102 | win = MainForm() 103 | win.show() 104 | sys.exit(app.exec_()) 105 | 106 | app() 107 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-05/MainWindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'MainWindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(495, 269) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.lbl_sayi1 = QtWidgets.QLabel(self.centralwidget) 20 | self.lbl_sayi1.setGeometry(QtCore.QRect(40, 60, 47, 14)) 21 | self.lbl_sayi1.setObjectName("lbl_sayi1") 22 | self.lbl_sayi2 = QtWidgets.QLabel(self.centralwidget) 23 | self.lbl_sayi2.setGeometry(QtCore.QRect(40, 90, 47, 14)) 24 | self.lbl_sayi2.setObjectName("lbl_sayi2") 25 | self.txt_sayi1 = QtWidgets.QLineEdit(self.centralwidget) 26 | self.txt_sayi1.setGeometry(QtCore.QRect(110, 60, 181, 20)) 27 | self.txt_sayi1.setObjectName("txt_sayi1") 28 | self.txt_sayi2 = QtWidgets.QLineEdit(self.centralwidget) 29 | self.txt_sayi2.setGeometry(QtCore.QRect(110, 90, 181, 20)) 30 | self.txt_sayi2.setObjectName("txt_sayi2") 31 | self.btn_topla = QtWidgets.QPushButton(self.centralwidget) 32 | self.btn_topla.setGeometry(QtCore.QRect(110, 130, 75, 23)) 33 | self.btn_topla.setObjectName("btn_topla") 34 | self.btn_cikarma = QtWidgets.QPushButton(self.centralwidget) 35 | self.btn_cikarma.setGeometry(QtCore.QRect(190, 130, 75, 23)) 36 | self.btn_cikarma.setObjectName("btn_cikarma") 37 | self.btn_carpma = QtWidgets.QPushButton(self.centralwidget) 38 | self.btn_carpma.setGeometry(QtCore.QRect(270, 130, 75, 23)) 39 | self.btn_carpma.setObjectName("btn_carpma") 40 | self.btn_bolme = QtWidgets.QPushButton(self.centralwidget) 41 | self.btn_bolme.setGeometry(QtCore.QRect(350, 130, 75, 23)) 42 | self.btn_bolme.setObjectName("btn_bolme") 43 | self.lbl_sonuc = QtWidgets.QLabel(self.centralwidget) 44 | self.lbl_sonuc.setGeometry(QtCore.QRect(110, 180, 301, 31)) 45 | self.lbl_sonuc.setObjectName("lbl_sonuc") 46 | MainWindow.setCentralWidget(self.centralwidget) 47 | self.menubar = QtWidgets.QMenuBar(MainWindow) 48 | self.menubar.setGeometry(QtCore.QRect(0, 0, 495, 22)) 49 | self.menubar.setObjectName("menubar") 50 | MainWindow.setMenuBar(self.menubar) 51 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 52 | self.statusbar.setObjectName("statusbar") 53 | MainWindow.setStatusBar(self.statusbar) 54 | 55 | self.retranslateUi(MainWindow) 56 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 57 | 58 | def retranslateUi(self, MainWindow): 59 | _translate = QtCore.QCoreApplication.translate 60 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 61 | self.lbl_sayi1.setText(_translate("MainWindow", "Sayi1 : ")) 62 | self.lbl_sayi2.setText(_translate("MainWindow", "Sayi 2 : ")) 63 | self.btn_topla.setText(_translate("MainWindow", "Toplam")) 64 | self.btn_cikarma.setText(_translate("MainWindow", "Cikarma")) 65 | self.btn_carpma.setText(_translate("MainWindow", "Carpma")) 66 | self.btn_bolme.setText(_translate("MainWindow", "Bolme")) 67 | self.lbl_sonuc.setText(_translate("MainWindow", "Sonuc : ")) 68 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-05/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 495 10 | 269 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 40 21 | 60 22 | 47 23 | 14 24 | 25 | 26 | 27 | Sayi1 : 28 | 29 | 30 | 31 | 32 | 33 | 40 34 | 90 35 | 47 36 | 14 37 | 38 | 39 | 40 | Sayi 2 : 41 | 42 | 43 | 44 | 45 | 46 | 110 47 | 60 48 | 181 49 | 20 50 | 51 | 52 | 53 | 54 | 55 | 56 | 110 57 | 90 58 | 181 59 | 20 60 | 61 | 62 | 63 | 64 | 65 | 66 | 110 67 | 130 68 | 75 69 | 23 70 | 71 | 72 | 73 | Toplam 74 | 75 | 76 | 77 | 78 | 79 | 190 80 | 130 81 | 75 82 | 23 83 | 84 | 85 | 86 | Cikarma 87 | 88 | 89 | 90 | 91 | 92 | 270 93 | 130 94 | 75 95 | 23 96 | 97 | 98 | 99 | Carpma 100 | 101 | 102 | 103 | 104 | 105 | 350 106 | 130 107 | 75 108 | 23 109 | 110 | 111 | 112 | Bolme 113 | 114 | 115 | 116 | 117 | 118 | 110 119 | 180 120 | 301 121 | 31 122 | 123 | 124 | 125 | Sonuc : 126 | 127 | 128 | 129 | 130 | 131 | 132 | 0 133 | 0 134 | 495 135 | 22 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-05/__pycache__/MainWindow.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-05/__pycache__/MainWindow.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-05/calculator.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | import sys 3 | from MainWindow import Ui_MainWindow 4 | 5 | class myApp(QtWidgets.QMainWindow): 6 | 7 | def __init__(self): 8 | super(myApp, self).__init__() 9 | self.ui = Ui_MainWindow() 10 | self.ui.setupUi(self) 11 | 12 | self.ui.btn_topla.clicked.connect(self.hesapla) 13 | self.ui.btn_cikarma.clicked.connect(self.hesapla) 14 | self.ui.btn_carpma.clicked.connect(self.hesapla) 15 | self.ui.btn_bolme.clicked.connect(self.hesapla) 16 | 17 | def hesapla(self): 18 | sender = self.sender().text() 19 | result = 0 20 | 21 | if sender == 'Toplam': 22 | result = int(self.ui.txt_sayi1.text()) + int(self.ui.txt_sayi2.text()) 23 | elif sender == 'Cikarma': 24 | result = int(self.ui.txt_sayi1.text()) - int(self.ui.txt_sayi2.text()) 25 | elif sender == 'Carpma': 26 | result = int(self.ui.txt_sayi1.text()) * int(self.ui.txt_sayi2.text()) 27 | elif sender == 'Bolme': 28 | result = int(self.ui.txt_sayi1.text()) / int(self.ui.txt_sayi2.text()) 29 | 30 | self.ui.lbl_sonuc.setText('sonuç: '+ str(result)) 31 | 32 | 33 | def app(): 34 | app = QtWidgets.QApplication(sys.argv) 35 | win = myApp() 36 | win.show() 37 | sys.exit(app.exec_()) 38 | 39 | app() 40 | 41 | 42 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-06/layouts.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | 19 | widget = Color('blue') 20 | self.setCentralWidget(widget) 21 | 22 | def app(): 23 | app = QApplication(sys.argv) 24 | win = MainWindow() 25 | win.show() 26 | sys.exit(app.exec_()) 27 | 28 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-06/layouts_.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | #layout = QtWidgets.QVBoxLayout() 21 | layout = QtWidgets.QHBoxLayout() 22 | 23 | layout.addWidget(Color('red')) 24 | layout.addWidget(Color('blue')) 25 | layout.addWidget(Color('green')) 26 | 27 | widget = QWidget() 28 | widget.setLayout(layout) 29 | 30 | self.setCentralWidget(widget) 31 | 32 | def app(): 33 | app = QApplication(sys.argv) 34 | win = MainWindow() 35 | win.show() 36 | sys.exit(app.exec_()) 37 | 38 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-06/layouts__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | hlayout1 = QtWidgets.QHBoxLayout() 21 | hlayout1.addWidget(Color('red')) 22 | hlayout1.addWidget(Color('green')) 23 | hlayout1.addWidget(Color('blue')) 24 | 25 | hlayout2 = QtWidgets.QHBoxLayout() 26 | hlayout2.addWidget(Color('red')) 27 | hlayout2.addWidget(Color('blue')) 28 | 29 | vlayout = QtWidgets.QVBoxLayout() 30 | vlayout.addLayout(hlayout1) 31 | vlayout.addLayout(hlayout2) 32 | 33 | widget = QWidget() 34 | widget.setLayout(vlayout) 35 | 36 | self.setCentralWidget(widget) 37 | 38 | def app(): 39 | app = QApplication(sys.argv) 40 | win = MainWindow() 41 | win.show() 42 | sys.exit(app.exec_()) 43 | 44 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-06/layouts___.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | layout = QtWidgets.QGridLayout() 21 | 22 | layout.addWidget(Color('red'),0,0) 23 | layout.addWidget(Color('green'),1,0) 24 | layout.addWidget(Color('blue'),0,2) 25 | layout.addWidget(Color('pink'),3,1) 26 | 27 | widget = QWidget() 28 | widget.setLayout(layout) 29 | 30 | self.setCentralWidget(widget) 31 | 32 | def app(): 33 | app = QApplication(sys.argv) 34 | win = MainWindow() 35 | win.show() 36 | sys.exit(app.exec_()) 37 | 38 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-06/layouts____.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | hlayout1 = QtWidgets.QHBoxLayout() 21 | hlayout1.addWidget(Color('red')) 22 | hlayout1.addWidget(Color('green')) 23 | hlayout1.addWidget(Color('blue')) 24 | #hlayout1.setContentsMargins(50,0,0,0) #bosluk birakiyor 25 | hlayout1.setContentsMargins(30,20,0,30) #bosluk birakiyor 26 | hlayout1.setSpacing(50) #her bir eleman arasinda bosluk olusturuluyor 27 | 28 | hlayout2 = QtWidgets.QHBoxLayout() 29 | hlayout2.addWidget(Color('red')) 30 | hlayout2.addWidget(Color('blue')) 31 | hlayout2.setSpacing(20) #her bir eleman arasinda bosluk olusturuluyor 32 | 33 | vlayout = QtWidgets.QVBoxLayout() 34 | vlayout.addLayout(hlayout1) 35 | vlayout.addLayout(hlayout2) 36 | 37 | widget = QWidget() 38 | widget.setLayout(vlayout) 39 | 40 | self.setCentralWidget(widget) 41 | 42 | def app(): 43 | app = QApplication(sys.argv) 44 | win = MainWindow() 45 | win.show() 46 | sys.exit(app.exec_()) 47 | 48 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-07/CheckBoxForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'CheckBoxForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(675, 431) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnGoster = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnGoster.setGeometry(QtCore.QRect(20, 200, 221, 41)) 21 | self.btnGoster.setObjectName("btnGoster") 22 | self.lblSonuc = QtWidgets.QLabel(self.centralwidget) 23 | self.lblSonuc.setGeometry(QtCore.QRect(20, 280, 291, 91)) 24 | self.lblSonuc.setObjectName("lblSonuc") 25 | self.groupHobiler = QtWidgets.QGroupBox(self.centralwidget) 26 | self.groupHobiler.setGeometry(QtCore.QRect(10, 20, 251, 161)) 27 | self.groupHobiler.setObjectName("groupHobiler") 28 | self.widget = QtWidgets.QWidget(self.groupHobiler) 29 | self.widget.setGeometry(QtCore.QRect(10, 30, 221, 111)) 30 | self.widget.setObjectName("widget") 31 | self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) 32 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) 33 | self.verticalLayout.setObjectName("verticalLayout") 34 | self.cbSinema = QtWidgets.QCheckBox(self.widget) 35 | self.cbSinema.setObjectName("cbSinema") 36 | self.verticalLayout.addWidget(self.cbSinema) 37 | self.cbKitap = QtWidgets.QCheckBox(self.widget) 38 | self.cbKitap.setObjectName("cbKitap") 39 | self.verticalLayout.addWidget(self.cbKitap) 40 | self.cbSpor = QtWidgets.QCheckBox(self.widget) 41 | self.cbSpor.setObjectName("cbSpor") 42 | self.verticalLayout.addWidget(self.cbSpor) 43 | self.groupDersler = QtWidgets.QGroupBox(self.centralwidget) 44 | self.groupDersler.setGeometry(QtCore.QRect(300, 20, 311, 161)) 45 | self.groupDersler.setObjectName("groupDersler") 46 | self.layoutWidget = QtWidgets.QWidget(self.groupDersler) 47 | self.layoutWidget.setGeometry(QtCore.QRect(10, 30, 291, 111)) 48 | self.layoutWidget.setObjectName("layoutWidget") 49 | self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget) 50 | self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) 51 | self.verticalLayout_2.setObjectName("verticalLayout_2") 52 | self.cbProgramlama = QtWidgets.QCheckBox(self.layoutWidget) 53 | self.cbProgramlama.setObjectName("cbProgramlama") 54 | self.verticalLayout_2.addWidget(self.cbProgramlama) 55 | self.cbGorsel = QtWidgets.QCheckBox(self.layoutWidget) 56 | self.cbGorsel.setObjectName("cbGorsel") 57 | self.verticalLayout_2.addWidget(self.cbGorsel) 58 | self.cbVeritabani = QtWidgets.QCheckBox(self.layoutWidget) 59 | self.cbVeritabani.setObjectName("cbVeritabani") 60 | self.verticalLayout_2.addWidget(self.cbVeritabani) 61 | self.btnGoster_dersler = QtWidgets.QPushButton(self.centralwidget) 62 | self.btnGoster_dersler.setGeometry(QtCore.QRect(310, 200, 221, 41)) 63 | self.btnGoster_dersler.setObjectName("btnGoster_dersler") 64 | self.lblSonuc_dersler = QtWidgets.QLabel(self.centralwidget) 65 | self.lblSonuc_dersler.setGeometry(QtCore.QRect(310, 280, 291, 91)) 66 | self.lblSonuc_dersler.setObjectName("lblSonuc_dersler") 67 | MainWindow.setCentralWidget(self.centralwidget) 68 | self.menubar = QtWidgets.QMenuBar(MainWindow) 69 | self.menubar.setGeometry(QtCore.QRect(0, 0, 675, 22)) 70 | self.menubar.setObjectName("menubar") 71 | MainWindow.setMenuBar(self.menubar) 72 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 73 | self.statusbar.setObjectName("statusbar") 74 | MainWindow.setStatusBar(self.statusbar) 75 | 76 | self.retranslateUi(MainWindow) 77 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 78 | 79 | def retranslateUi(self, MainWindow): 80 | _translate = QtCore.QCoreApplication.translate 81 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 82 | self.btnGoster.setText(_translate("MainWindow", "Secilenleri Goster")) 83 | self.lblSonuc.setText(_translate("MainWindow", "TextLabel")) 84 | self.groupHobiler.setTitle(_translate("MainWindow", "GroupBox")) 85 | self.cbSinema.setText(_translate("MainWindow", "Sinemaya gitmek")) 86 | self.cbKitap.setText(_translate("MainWindow", "Kitap okumak")) 87 | self.cbSpor.setText(_translate("MainWindow", "Spor yapmak")) 88 | self.groupDersler.setTitle(_translate("MainWindow", "GroupBox")) 89 | self.cbProgramlama.setText(_translate("MainWindow", "Programlama Temelleri")) 90 | self.cbGorsel.setText(_translate("MainWindow", "Gorsel Programlama")) 91 | self.cbVeritabani.setText(_translate("MainWindow", "Veri Tabani")) 92 | self.btnGoster_dersler.setText(_translate("MainWindow", "Secilenleri Goster")) 93 | self.lblSonuc_dersler.setText(_translate("MainWindow", "TextLabel")) 94 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-07/CheckBoxForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 675 10 | 431 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 20 21 | 200 22 | 221 23 | 41 24 | 25 | 26 | 27 | Secilenleri Goster 28 | 29 | 30 | 31 | 32 | 33 | 20 34 | 280 35 | 291 36 | 91 37 | 38 | 39 | 40 | TextLabel 41 | 42 | 43 | 44 | 45 | 46 | 10 47 | 20 48 | 251 49 | 161 50 | 51 | 52 | 53 | GroupBox 54 | 55 | 56 | 57 | 58 | 10 59 | 30 60 | 221 61 | 111 62 | 63 | 64 | 65 | 66 | 67 | 68 | Sinemaya gitmek 69 | 70 | 71 | 72 | 73 | 74 | 75 | Kitap okumak 76 | 77 | 78 | 79 | 80 | 81 | 82 | Spor yapmak 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 300 93 | 20 94 | 311 95 | 161 96 | 97 | 98 | 99 | GroupBox 100 | 101 | 102 | 103 | 104 | 10 105 | 30 106 | 291 107 | 111 108 | 109 | 110 | 111 | 112 | 113 | 114 | Programlama Temelleri 115 | 116 | 117 | 118 | 119 | 120 | 121 | Gorsel Programlama 122 | 123 | 124 | 125 | 126 | 127 | 128 | Veri Tabani 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 310 139 | 200 140 | 221 141 | 41 142 | 143 | 144 | 145 | Secilenleri Goster 146 | 147 | 148 | 149 | 150 | 151 | 310 152 | 280 153 | 291 154 | 91 155 | 156 | 157 | 158 | TextLabel 159 | 160 | 161 | 162 | 163 | 164 | 165 | 0 166 | 0 167 | 675 168 | 22 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-07/__pycache__/CheckBoxForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-07/__pycache__/CheckBoxForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-07/checkBox_.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from CheckBoxForm import Ui_MainWindow 4 | 5 | class myApp(QtWidgets.QMainWindow): 6 | def __init__(self): 7 | super(myApp,self).__init__() 8 | 9 | self.ui = Ui_MainWindow() 10 | self.ui.setupUi(self) 11 | 12 | self.ui.cbSinema.stateChanged.connect(self.show_state) 13 | self.ui.cbKitap.stateChanged.connect(self.show_state) 14 | self.ui.cbSpor.stateChanged.connect(self.show_state) 15 | 16 | self.ui.btnGoster.clicked.connect(self.getAllHobiler) 17 | self.ui.btnGoster_dersler.clicked.connect(self.getAllDersler) 18 | 19 | def getAllHobiler(self): 20 | sonuc = '' 21 | # items = self.ui.centralwidget.findChildren(QtWidgets.QCheckBox) #form uzerindeki tum chckbx larin bilgileri toplaniyor 22 | 23 | items = self.ui.groupHobiler.findChildren(QtWidgets.QCheckBox) #form uzerindeki tum chckbx larin bilgileri toplaniyor 24 | for cb in items: 25 | if cb.isChecked(): 26 | sonuc += cb.text() + '\n' 27 | self.ui.lblSonuc.setText(sonuc) 28 | 29 | def getAllDersler(self): 30 | sonuc = '' 31 | # items = self.ui.centralwidget.findChildren(QtWidgets.QCheckBox) #form uzerindeki tum chckbx larin bilgileri toplaniyor 32 | 33 | items = self.ui.groupDersler.findChildren(QtWidgets.QCheckBox) #form uzerindeki tum chckbx larin bilgileri toplaniyor 34 | for cb in items: 35 | if cb.isChecked(): 36 | sonuc += cb.text() + '\n' 37 | self.ui.lblSonuc_dersler.setText(sonuc) 38 | 39 | def show_state(self, value): 40 | #print(value) 41 | #print(self.ui.cbSinema.isChecked()) 42 | #print(self.ui.cbSinema.text()) 43 | cb = self.sender() 44 | #print(value) 45 | #print(cb.text()) 46 | #print(cb.isChecked()) 47 | 48 | def app(): 49 | app = QtWidgets.QApplication(sys.argv) 50 | win = myApp() 51 | win.show() 52 | sys.exit(app.exec_()) 53 | 54 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-08/__pycache__/RadioButtonForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-08/__pycache__/RadioButtonForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-08/radioButton_.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from RadioButtonForm import Ui_MainWindow 4 | 5 | class Window(QtWidgets.QMainWindow): 6 | def __init__(self): 7 | super(Window, self).__init__() 8 | 9 | self.ui = Ui_MainWindow() 10 | self.ui.setupUi(self) 11 | 12 | self.ui.radioTurkiye.setChecked(True) 13 | self.ui.radioLise.setChecked(True) 14 | 15 | self.ui.radioTurkiye.toggled.connect(self.onClickedUlke) 16 | self.ui.radioAzerbaycan.toggled.connect(self.onClickedUlke) 17 | self.ui.radioAlmanya.toggled.connect(self.onClickedUlke) 18 | self.ui.radioYunanistan.toggled.connect(self.onClickedUlke) 19 | 20 | self.ui.radioilkokul.toggled.connect(self.onClickedEgitim) 21 | self.ui.radioLise.toggled.connect(self.onClickedEgitim) 22 | self.ui.radioUniversite.toggled.connect(self.onClickedEgitim) 23 | self.ui.radioYuksekLisans.toggled.connect(self.onClickedEgitim) 24 | 25 | self.ui.btnUlke.clicked.connect(self.getSelectedUlke) 26 | self.ui.btnEgitim.clicked.connect(self.getSelectedEgitim) 27 | 28 | def onClickedUlke(self): 29 | rb = self.sender() 30 | if rb.isChecked(): 31 | print('secilen radyo : ' + rb.text()) 32 | 33 | 34 | def onClickedEgitim(self): 35 | rb = self.sender() 36 | if rb.isChecked(): 37 | print('secilen ulke : ' + rb.text()) 38 | 39 | def getSelectedUlke(self): 40 | items = self.ui.groupBoxUlke.findChildren(QtWidgets.QRadioButton) 41 | for rb in items: 42 | if rb.isChecked(): 43 | self.ui.lblUlke.setText('Secilen Ulke : ' + rb.text()) 44 | 45 | def getSelectedEgitim(self): 46 | items = self.ui.groupBoxEgitim.findChildren(QtWidgets.QRadioButton) 47 | for rb in items: 48 | if rb.isChecked(): 49 | self.ui.lblEgitim.setText('Secilen Egitim : ' + rb.text()) 50 | 51 | 52 | def app(): 53 | app = QtWidgets.QApplication(sys.argv) 54 | win = Window() 55 | win.show() 56 | sys.exit(app.exec_()) 57 | 58 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-09/ComboBoxForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'ComboBoxForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(403, 311) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.cbSehirler = QtWidgets.QComboBox(self.centralwidget) 20 | self.cbSehirler.setGeometry(QtCore.QRect(50, 20, 151, 41)) 21 | self.cbSehirler.setObjectName("cbSehirler") 22 | self.lblResult = QtWidgets.QLabel(self.centralwidget) 23 | self.lblResult.setGeometry(QtCore.QRect(220, 20, 141, 41)) 24 | self.lblResult.setObjectName("lblResult") 25 | self.btnGetItem = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGetItem.setGeometry(QtCore.QRect(50, 90, 151, 41)) 27 | self.btnGetItem.setObjectName("btnGetItem") 28 | self.btnLoadItems = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnLoadItems.setGeometry(QtCore.QRect(220, 90, 151, 41)) 30 | self.btnLoadItems.setObjectName("btnLoadItems") 31 | self.btnClear = QtWidgets.QPushButton(self.centralwidget) 32 | self.btnClear.setGeometry(QtCore.QRect(50, 140, 151, 41)) 33 | self.btnClear.setObjectName("btnClear") 34 | MainWindow.setCentralWidget(self.centralwidget) 35 | self.menubar = QtWidgets.QMenuBar(MainWindow) 36 | self.menubar.setGeometry(QtCore.QRect(0, 0, 403, 18)) 37 | self.menubar.setObjectName("menubar") 38 | MainWindow.setMenuBar(self.menubar) 39 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 40 | self.statusbar.setObjectName("statusbar") 41 | MainWindow.setStatusBar(self.statusbar) 42 | 43 | self.retranslateUi(MainWindow) 44 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 45 | 46 | def retranslateUi(self, MainWindow): 47 | _translate = QtCore.QCoreApplication.translate 48 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 49 | self.lblResult.setText(_translate("MainWindow", "TextLabel")) 50 | self.btnGetItem.setText(_translate("MainWindow", "Get Item")) 51 | self.btnLoadItems.setText(_translate("MainWindow", "Load Items")) 52 | self.btnClear.setText(_translate("MainWindow", "Clear Items")) 53 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-09/ComboBoxForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 403 10 | 311 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 50 21 | 20 22 | 151 23 | 41 24 | 25 | 26 | 27 | 28 | 29 | 30 | 220 31 | 20 32 | 141 33 | 41 34 | 35 | 36 | 37 | TextLabel 38 | 39 | 40 | 41 | 42 | 43 | 50 44 | 90 45 | 151 46 | 41 47 | 48 | 49 | 50 | Get Item 51 | 52 | 53 | 54 | 55 | 56 | 220 57 | 90 58 | 151 59 | 41 60 | 61 | 62 | 63 | Load Items 64 | 65 | 66 | 67 | 68 | 69 | 50 70 | 140 71 | 151 72 | 41 73 | 74 | 75 | 76 | Clear Items 77 | 78 | 79 | 80 | 81 | 82 | 83 | 0 84 | 0 85 | 403 86 | 18 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-09/__pycache__/ComboBoxForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-09/__pycache__/ComboBoxForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-09/comboBox_.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from ComboBoxForm import Ui_MainWindow 4 | 5 | class Window(QtWidgets.QMainWindow): 6 | def __init__(self): 7 | super(Window, self).__init__() 8 | 9 | self.ui = Ui_MainWindow() 10 | self.ui.setupUi(self) 11 | 12 | combo = self.ui.cbSehirler 13 | 14 | # combo.addItem('Ankara') 15 | # combo.addItem('İstanbul') 16 | # combo.addItem('Kocaeli') 17 | # combo.addItems(['Adana','İzmir','Rize']) 18 | 19 | self.ui.btnLoadItems.clicked.connect(self.LoadItems) 20 | self.ui.btnGetItem.clicked.connect(self.GetItem) 21 | self.ui.btnClear.clicked.connect(self.ClearItems) 22 | 23 | self.ui.cbSehirler.currentIndexChanged.connect(self.SelectedChangedIndex) 24 | self.ui.cbSehirler.currentIndexChanged[str].connect(self.SelectedChangedText) 25 | 26 | def ClearItems(self): 27 | self.ui.cbSehirler.clear() 28 | 29 | def LoadItems(self): 30 | sehirler = ['Adana','İzmir','Rize'] 31 | 32 | self.ui.cbSehirler.addItems(sehirler) 33 | 34 | def GetItem(self): 35 | print(self.ui.cbSehirler.currentText()) 36 | print(self.ui.cbSehirler.currentIndex()) 37 | 38 | count = self.ui.cbSehirler.count() 39 | for index in range(count): 40 | print(self.ui.cbSehirler.itemText(index)) 41 | 42 | def SelectedChangedIndex(self, index): 43 | print(index) 44 | 45 | def SelectedChangedText(self, text): 46 | print(text) 47 | 48 | def app(): 49 | app = QtWidgets.QApplication(sys.argv) 50 | win = Window() 51 | win.show() 52 | sys.exit(app.exec_()) 53 | 54 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-10/MsgBoxForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'MsgBoxForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(506, 342) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnExit = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnExit.setGeometry(QtCore.QRect(140, 80, 171, 71)) 21 | self.btnExit.setObjectName("btnExit") 22 | MainWindow.setCentralWidget(self.centralwidget) 23 | self.menubar = QtWidgets.QMenuBar(MainWindow) 24 | self.menubar.setGeometry(QtCore.QRect(0, 0, 506, 18)) 25 | self.menubar.setObjectName("menubar") 26 | MainWindow.setMenuBar(self.menubar) 27 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 28 | self.statusbar.setObjectName("statusbar") 29 | MainWindow.setStatusBar(self.statusbar) 30 | 31 | self.retranslateUi(MainWindow) 32 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 33 | 34 | def retranslateUi(self, MainWindow): 35 | _translate = QtCore.QCoreApplication.translate 36 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 37 | self.btnExit.setText(_translate("MainWindow", "Exit")) 38 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-10/MsgBoxForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 506 10 | 342 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 140 21 | 80 22 | 171 23 | 71 24 | 25 | 26 | 27 | Exit 28 | 29 | 30 | 31 | 32 | 33 | 34 | 0 35 | 0 36 | 506 37 | 18 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-10/__pycache__/MsgBoxForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-10/__pycache__/MsgBoxForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-10/msgBox_.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | from PyQt5.QtWidgets import QMessageBox 3 | from MsgBoxForm import Ui_MainWindow 4 | import sys 5 | 6 | class Window(QtWidgets.QMainWindow): 7 | def __init__(self): 8 | super(Window, self).__init__() 9 | 10 | self.ui = Ui_MainWindow() 11 | self.ui.setupUi(self) 12 | 13 | self.ui.btnExit.clicked.connect(self.showDialog) 14 | 15 | def showDialog(self): 16 | 17 | result = QMessageBox.question(self, 'Close Application', 'Are you sure ?', QMessageBox.Ok | QMessageBox.Cancel | QMessageBox.Ignore, QMessageBox.Cancel) 18 | if result == QMessageBox.Ok: 19 | print('Yes clicked') 20 | QtWidgets.qApp.quit() 21 | else: 22 | print('No clicked') 23 | 24 | # msg = QMessageBox() 25 | 26 | # msg.setWindowTitle('Close Application') 27 | # msg.setText('Are you sure ?') 28 | # msg.setIcon(QMessageBox.Warning) 29 | # msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel | QMessageBox.Ignore) 30 | # msg.setDefaultButton(QMessageBox.Cancel) 31 | # msg.setDetailedText('details....') 32 | # msg.buttonClicked.connect(self.popup_button) 33 | 34 | # x = msg.exec_() 35 | # print(x) 36 | 37 | # def popup_button(self, i): 38 | # print(i.text()) 39 | 40 | # if i.text() == 'OK': 41 | # print('OKEY...') 42 | # QtWidgets.qApp.quit() 43 | # elif i.text() == 'Cancel': 44 | # print('Cancel...') 45 | # else: 46 | # print('Ignore...') 47 | 48 | def app(): 49 | app = QtWidgets.QApplication(sys.argv) 50 | win = Window() 51 | win.show() 52 | sys.exit(app.exec_()) 53 | 54 | app() 55 | 56 | 57 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-11/DateTimeForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'DateTimeForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(547, 327) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.timeEdit = QtWidgets.QTimeEdit(self.centralwidget) 20 | self.timeEdit.setGeometry(QtCore.QRect(50, 100, 141, 41)) 21 | self.timeEdit.setCalendarPopup(True) 22 | self.timeEdit.setObjectName("timeEdit") 23 | self.dateTimeEdit = QtWidgets.QDateTimeEdit(self.centralwidget) 24 | self.dateTimeEdit.setGeometry(QtCore.QRect(200, 100, 231, 41)) 25 | self.dateTimeEdit.setCalendarPopup(True) 26 | self.dateTimeEdit.setObjectName("dateTimeEdit") 27 | self.btnCalculate = QtWidgets.QPushButton(self.centralwidget) 28 | self.btnCalculate.setGeometry(QtCore.QRect(50, 170, 131, 41)) 29 | self.btnCalculate.setObjectName("btnCalculate") 30 | self.layoutWidget = QtWidgets.QWidget(self.centralwidget) 31 | self.layoutWidget.setGeometry(QtCore.QRect(50, 30, 351, 31)) 32 | self.layoutWidget.setObjectName("layoutWidget") 33 | self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget) 34 | self.horizontalLayout.setContentsMargins(0, 0, 0, 0) 35 | self.horizontalLayout.setObjectName("horizontalLayout") 36 | self.dateStart = QtWidgets.QDateEdit(self.layoutWidget) 37 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) 38 | sizePolicy.setHorizontalStretch(0) 39 | sizePolicy.setVerticalStretch(0) 40 | sizePolicy.setHeightForWidth(self.dateStart.sizePolicy().hasHeightForWidth()) 41 | self.dateStart.setSizePolicy(sizePolicy) 42 | self.dateStart.setCalendarPopup(True) 43 | self.dateStart.setDate(QtCore.QDate(2001, 1, 1)) 44 | self.dateStart.setObjectName("dateStart") 45 | self.horizontalLayout.addWidget(self.dateStart) 46 | spacerItem = QtWidgets.QSpacerItem(70, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) 47 | self.horizontalLayout.addItem(spacerItem) 48 | self.dateEnd = QtWidgets.QDateEdit(self.layoutWidget) 49 | sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) 50 | sizePolicy.setHorizontalStretch(0) 51 | sizePolicy.setVerticalStretch(0) 52 | sizePolicy.setHeightForWidth(self.dateEnd.sizePolicy().hasHeightForWidth()) 53 | self.dateEnd.setSizePolicy(sizePolicy) 54 | self.dateEnd.setObjectName("dateEnd") 55 | self.horizontalLayout.addWidget(self.dateEnd) 56 | MainWindow.setCentralWidget(self.centralwidget) 57 | self.menubar = QtWidgets.QMenuBar(MainWindow) 58 | self.menubar.setGeometry(QtCore.QRect(0, 0, 547, 22)) 59 | self.menubar.setObjectName("menubar") 60 | MainWindow.setMenuBar(self.menubar) 61 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 62 | self.statusbar.setObjectName("statusbar") 63 | MainWindow.setStatusBar(self.statusbar) 64 | 65 | self.retranslateUi(MainWindow) 66 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 67 | 68 | def retranslateUi(self, MainWindow): 69 | _translate = QtCore.QCoreApplication.translate 70 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 71 | self.btnCalculate.setText(_translate("MainWindow", "PushButton")) 72 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-11/DateTimeForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 547 10 | 327 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 50 21 | 100 22 | 141 23 | 41 24 | 25 | 26 | 27 | true 28 | 29 | 30 | 31 | 32 | 33 | 200 34 | 100 35 | 231 36 | 41 37 | 38 | 39 | 40 | true 41 | 42 | 43 | 44 | 45 | 46 | 50 47 | 170 48 | 131 49 | 41 50 | 51 | 52 | 53 | PushButton 54 | 55 | 56 | 57 | 58 | 59 | 50 60 | 30 61 | 351 62 | 31 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 0 71 | 0 72 | 73 | 74 | 75 | true 76 | 77 | 78 | 79 | 2001 80 | 1 81 | 1 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | Qt::Horizontal 90 | 91 | 92 | QSizePolicy::Fixed 93 | 94 | 95 | 96 | 70 97 | 20 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 0 107 | 0 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 0 119 | 0 120 | 547 121 | 22 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-11/__pycache__/DateTimeForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-11/__pycache__/DateTimeForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-11/dateTime_.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from DateTimeForm import Ui_MainWindow 4 | from PyQt5.QtCore import QDate, QTime, QDateTime 5 | 6 | class myApp(QtWidgets.QMainWindow): 7 | def __init__(self): 8 | super(myApp, self).__init__() 9 | 10 | self.ui = Ui_MainWindow() 11 | self.ui.setupUi(self) 12 | 13 | self.ui.btnCalculate.clicked.connect(self.calculate) 14 | 15 | def calculate(self): 16 | start = self.ui.dateStart.date() 17 | end = self.ui.dateEnd.date() 18 | print(start, end) 19 | 20 | print('Days in month: {0}'.format(start.daysInMonth())) 21 | print('Days in year: {0}'.format(start.daysInYear())) 22 | 23 | print('total days: {0}'.format(start.daysTo(end))) 24 | 25 | now = QDate.currentDate() 26 | 27 | print('total days from now: {0}'.format(start.daysTo(now))) 28 | 29 | 30 | def app(): 31 | app = QtWidgets.QApplication(sys.argv) 32 | win = myApp() 33 | win.show() 34 | sys.exit(app.exec_()) 35 | 36 | app() -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-12/ListWidgetForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'ListWidgetForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(800, 600) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.listItems = QtWidgets.QListWidget(self.centralwidget) 20 | self.listItems.setGeometry(QtCore.QRect(30, 30, 291, 261)) 21 | self.listItems.setObjectName("listItems") 22 | self.widget = QtWidgets.QWidget(self.centralwidget) 23 | self.widget.setGeometry(QtCore.QRect(370, 30, 101, 261)) 24 | self.widget.setObjectName("widget") 25 | self.verticalLayout = QtWidgets.QVBoxLayout(self.widget) 26 | self.verticalLayout.setContentsMargins(0, 0, 0, 0) 27 | self.verticalLayout.setObjectName("verticalLayout") 28 | self.btnAdd = QtWidgets.QPushButton(self.widget) 29 | self.btnAdd.setObjectName("btnAdd") 30 | self.verticalLayout.addWidget(self.btnAdd) 31 | self.btnEdit = QtWidgets.QPushButton(self.widget) 32 | self.btnEdit.setObjectName("btnEdit") 33 | self.verticalLayout.addWidget(self.btnEdit) 34 | self.btnRemove = QtWidgets.QPushButton(self.widget) 35 | self.btnRemove.setObjectName("btnRemove") 36 | self.verticalLayout.addWidget(self.btnRemove) 37 | self.btnUp = QtWidgets.QPushButton(self.widget) 38 | self.btnUp.setObjectName("btnUp") 39 | self.verticalLayout.addWidget(self.btnUp) 40 | self.btnDown = QtWidgets.QPushButton(self.widget) 41 | self.btnDown.setObjectName("btnDown") 42 | self.verticalLayout.addWidget(self.btnDown) 43 | self.btnSort = QtWidgets.QPushButton(self.widget) 44 | self.btnSort.setObjectName("btnSort") 45 | self.verticalLayout.addWidget(self.btnSort) 46 | spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) 47 | self.verticalLayout.addItem(spacerItem) 48 | self.btnExit = QtWidgets.QPushButton(self.widget) 49 | self.btnExit.setObjectName("btnExit") 50 | self.verticalLayout.addWidget(self.btnExit) 51 | MainWindow.setCentralWidget(self.centralwidget) 52 | self.menubar = QtWidgets.QMenuBar(MainWindow) 53 | self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 18)) 54 | self.menubar.setObjectName("menubar") 55 | MainWindow.setMenuBar(self.menubar) 56 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 57 | self.statusbar.setObjectName("statusbar") 58 | MainWindow.setStatusBar(self.statusbar) 59 | 60 | self.retranslateUi(MainWindow) 61 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 62 | 63 | def retranslateUi(self, MainWindow): 64 | _translate = QtCore.QCoreApplication.translate 65 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 66 | self.btnAdd.setText(_translate("MainWindow", "Add")) 67 | self.btnEdit.setText(_translate("MainWindow", "Edit")) 68 | self.btnRemove.setText(_translate("MainWindow", "Remove")) 69 | self.btnUp.setText(_translate("MainWindow", "Up")) 70 | self.btnDown.setText(_translate("MainWindow", "Down")) 71 | self.btnSort.setText(_translate("MainWindow", "Sort")) 72 | self.btnExit.setText(_translate("MainWindow", "Exit")) 73 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-12/ListWidgetForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 30 21 | 30 22 | 291 23 | 261 24 | 25 | 26 | 27 | 28 | 29 | 30 | 370 31 | 30 32 | 101 33 | 261 34 | 35 | 36 | 37 | 38 | 39 | 40 | Add 41 | 42 | 43 | 44 | 45 | 46 | 47 | Edit 48 | 49 | 50 | 51 | 52 | 53 | 54 | Remove 55 | 56 | 57 | 58 | 59 | 60 | 61 | Up 62 | 63 | 64 | 65 | 66 | 67 | 68 | Down 69 | 70 | 71 | 72 | 73 | 74 | 75 | Sort 76 | 77 | 78 | 79 | 80 | 81 | 82 | Qt::Vertical 83 | 84 | 85 | 86 | 20 87 | 40 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | Exit 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 0 106 | 0 107 | 800 108 | 22 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-12/__pycache__/ListBoxForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-12/__pycache__/ListBoxForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-12/__pycache__/ListWidgetForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-12/__pycache__/ListWidgetForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-12/listBox_.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | from PyQt5.QtWidgets import QInputDialog, QLineEdit, QMessageBox 3 | from ListWidgetForm import Ui_MainWindow 4 | import sys 5 | 6 | class Window(QtWidgets.QMainWindow): 7 | def __init__(self): 8 | super(Window, self).__init__() 9 | 10 | self.ui = Ui_MainWindow() 11 | self.ui.setupUi(self) 12 | 13 | # load Students 14 | self.loadStudents() 15 | 16 | # add New Student 17 | self.ui.btnAdd.clicked.connect(self.addStudent) 18 | 19 | # edit Student 20 | self.ui.btnEdit.clicked.connect(self.editStudent) 21 | 22 | # delete Student 23 | self.ui.btnRemove.clicked.connect(self.removeStudent) 24 | 25 | # Up 26 | self.ui.btnUp.clicked.connect(self.upStudent) 27 | 28 | # Down 29 | self.ui.btnDown.clicked.connect(self.downStudent) 30 | 31 | # sort 32 | self.ui.btnSort.clicked.connect(self.sortStudents) 33 | 34 | # close 35 | self.ui.btnExit.clicked.connect(self.close) 36 | 37 | def loadStudents(self): 38 | self.ui.listItems.addItems(['Hatice','Yagmur','Fatih']) 39 | self.ui.listItems.setCurrentRow(1) 40 | 41 | def addStudent(self): 42 | currentIndex = self.ui.listItems.currentRow() 43 | text, ok = QInputDialog.getText(self, "New Student", "Student Name") 44 | if ok and text is not None: 45 | self.ui.listItems.insertItem(currentIndex ,text) 46 | 47 | def editStudent(self): 48 | index = self.ui.listItems.currentRow() 49 | item = self.ui.listItems.item(index) 50 | 51 | if item is not None: 52 | text, ok = QInputDialog.getText(self, "Edit Student", "Student Name", QLineEdit.Normal, item.text()) 53 | if text and ok is not None: 54 | item.setText(text) 55 | 56 | def removeStudent(self): 57 | index = self.ui.listItems.currentRow() 58 | item = self.ui.listItems.item(index) 59 | 60 | if item is None: 61 | return 62 | 63 | q = QMessageBox.question(self, "Remove Student", "Do you want to remove student: " + item.text(), QMessageBox.Yes | QMessageBox.No) 64 | if q == QMessageBox.Yes: 65 | item = self.ui.listItems.takeItem(index) 66 | del item 67 | 68 | def upStudent(self): 69 | index = self.ui.listItems.currentRow() 70 | if index >= 1: 71 | item = self.ui.listItems.takeItem(index) 72 | self.ui.listItems.insertItem(index-1, item) 73 | self.ui.listItems.setCurrentItem(item) 74 | 75 | def downStudent(self): 76 | index = self.ui.listItems.currentRow() 77 | if index < self.ui.listItems.count()-1: 78 | item = self.ui.listItems.takeItem(index) 79 | self.ui.listItems.insertItem(index+1, item) 80 | self.ui.listItems.setCurrentItem(item) 81 | 82 | def sortStudents(self): 83 | self.ui.listItems.sortItems() 84 | 85 | def close(self): 86 | quit() 87 | 88 | def app(): 89 | app = QtWidgets.QApplication(sys.argv) 90 | win = Window() 91 | win.show() 92 | sys.exit(app.exec_()) 93 | 94 | app() 95 | 96 | 97 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-13/TableViewForm.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1057 10 | 600 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 280 21 | 10 22 | 651 23 | 461 24 | 25 | 26 | 27 | 28 | 29 | 30 | 10 31 | 10 32 | 231 33 | 171 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | Price 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Save 54 | 55 | 56 | 57 | 58 | 59 | 60 | Name 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 0 71 | 0 72 | 1057 73 | 22 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-13/TableviewForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'TableviewForm.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(1057, 600) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.tableProducts = QtWidgets.QTableWidget(self.centralwidget) 20 | self.tableProducts.setGeometry(QtCore.QRect(280, 10, 651, 461)) 21 | self.tableProducts.setObjectName("tableProducts") 22 | self.tableProducts.setColumnCount(0) 23 | self.tableProducts.setRowCount(0) 24 | self.formLayoutWidget = QtWidgets.QWidget(self.centralwidget) 25 | self.formLayoutWidget.setGeometry(QtCore.QRect(10, 10, 231, 171)) 26 | self.formLayoutWidget.setObjectName("formLayoutWidget") 27 | self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget) 28 | self.formLayout.setContentsMargins(0, 0, 0, 0) 29 | self.formLayout.setObjectName("formLayout") 30 | self.txtName = QtWidgets.QLineEdit(self.formLayoutWidget) 31 | self.txtName.setObjectName("txtName") 32 | self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.txtName) 33 | self.label_2 = QtWidgets.QLabel(self.formLayoutWidget) 34 | self.label_2.setObjectName("label_2") 35 | self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_2) 36 | self.txtPrice = QtWidgets.QLineEdit(self.formLayoutWidget) 37 | self.txtPrice.setObjectName("txtPrice") 38 | self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.txtPrice) 39 | self.btnSave = QtWidgets.QPushButton(self.formLayoutWidget) 40 | self.btnSave.setObjectName("btnSave") 41 | self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.btnSave) 42 | self.label = QtWidgets.QLabel(self.formLayoutWidget) 43 | self.label.setObjectName("label") 44 | self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label) 45 | MainWindow.setCentralWidget(self.centralwidget) 46 | self.menubar = QtWidgets.QMenuBar(MainWindow) 47 | self.menubar.setGeometry(QtCore.QRect(0, 0, 1057, 22)) 48 | self.menubar.setObjectName("menubar") 49 | MainWindow.setMenuBar(self.menubar) 50 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 51 | self.statusbar.setObjectName("statusbar") 52 | MainWindow.setStatusBar(self.statusbar) 53 | 54 | self.retranslateUi(MainWindow) 55 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 56 | 57 | def retranslateUi(self, MainWindow): 58 | _translate = QtCore.QCoreApplication.translate 59 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 60 | self.label_2.setText(_translate("MainWindow", "Price")) 61 | self.btnSave.setText(_translate("MainWindow", "Save")) 62 | self.label.setText(_translate("MainWindow", "Name")) 63 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-13/__pycache__/TableviewForm.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/02-QT-Designer-Examples/exp-13/__pycache__/TableviewForm.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/exp-13/tableView_.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | from PyQt5.QtWidgets import QTableWidgetItem 3 | from TableviewForm import Ui_MainWindow 4 | import sys 5 | 6 | class Window(QtWidgets.QMainWindow): 7 | def __init__(self): 8 | super(Window, self).__init__() 9 | 10 | self.ui = Ui_MainWindow() 11 | self.ui.setupUi(self) 12 | 13 | self.loadProducts() 14 | self.ui.btnSave.clicked.connect(self.saveProduct) 15 | self.ui.tableProducts.doubleClicked.connect(self.doubleClick) 16 | 17 | def doubleClick(self): 18 | for item in self.ui.tableProducts.selectedItems(): 19 | print(item.row(), item.column(), item.text()) 20 | 21 | 22 | def saveProduct(self): 23 | name = self.ui.txtName.text() 24 | price = self.ui.txtPrice.text() 25 | 26 | if name and price is not None: 27 | rowCount = self.ui.tableProducts.rowCount() 28 | print(rowCount) 29 | self.ui.tableProducts.insertRow(rowCount) 30 | self.ui.tableProducts.setItem(rowCount,0, QTableWidgetItem(name)) 31 | self.ui.tableProducts.setItem(rowCount,1, QTableWidgetItem(price)) 32 | 33 | def loadProducts(self): 34 | 35 | products = [ 36 | {'name': 'Samsung S5', 'price': 2000}, 37 | {'name': 'Samsung S6', 'price': 3000}, 38 | {'name': 'Samsung S7', 'price': 4000}, 39 | {'name': 'Samsung S8', 'price': 5000} 40 | ] 41 | 42 | self.ui.tableProducts.setRowCount(len(products)) 43 | self.ui.tableProducts.setColumnCount(2) 44 | self.ui.tableProducts.setHorizontalHeaderLabels(('Name','Price')) 45 | self.ui.tableProducts.setColumnWidth(0,200) 46 | self.ui.tableProducts.setColumnWidth(1,100) 47 | 48 | rowIndex = 0 49 | for product in products: 50 | self.ui.tableProducts.setItem(rowIndex,0, QTableWidgetItem(product['name'])) 51 | self.ui.tableProducts.setItem(rowIndex,1, QTableWidgetItem(str(product['price']))) 52 | 53 | rowIndex+=1 54 | 55 | def app(): 56 | app = QtWidgets.QApplication(sys.argv) 57 | win = Window() 58 | win.show() 59 | sys.exit(app.exec_()) 60 | 61 | app() 62 | 63 | 64 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/intro/TelefonDefteriGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'TelefonDefteriGUI.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(910, 723) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnKaydet = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnKaydet.setGeometry(QtCore.QRect(560, 20, 211, 41)) 21 | self.btnKaydet.setObjectName("btnKaydet") 22 | self.btnSil = QtWidgets.QPushButton(self.centralwidget) 23 | self.btnSil.setGeometry(QtCore.QRect(560, 70, 211, 41)) 24 | self.btnSil.setObjectName("btnSil") 25 | self.btnGuncelle = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGuncelle.setGeometry(QtCore.QRect(560, 120, 211, 41)) 27 | self.btnGuncelle.setObjectName("btnGuncelle") 28 | self.btnListele = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnListele.setGeometry(QtCore.QRect(560, 170, 211, 41)) 30 | self.btnListele.setObjectName("btnListele") 31 | self.txtID = QtWidgets.QLineEdit(self.centralwidget) 32 | self.txtID.setGeometry(QtCore.QRect(220, 20, 311, 41)) 33 | self.txtID.setObjectName("txtID") 34 | self.txtIsim = QtWidgets.QLineEdit(self.centralwidget) 35 | self.txtIsim.setGeometry(QtCore.QRect(220, 70, 311, 41)) 36 | self.txtIsim.setObjectName("txtIsim") 37 | self.txtSoyisim = QtWidgets.QLineEdit(self.centralwidget) 38 | self.txtSoyisim.setGeometry(QtCore.QRect(220, 120, 311, 41)) 39 | self.txtSoyisim.setObjectName("txtSoyisim") 40 | self.txtSehir = QtWidgets.QLineEdit(self.centralwidget) 41 | self.txtSehir.setGeometry(QtCore.QRect(220, 170, 311, 41)) 42 | self.txtSehir.setObjectName("txtSehir") 43 | self.txtTelefon = QtWidgets.QLineEdit(self.centralwidget) 44 | self.txtTelefon.setGeometry(QtCore.QRect(220, 220, 311, 41)) 45 | self.txtTelefon.setObjectName("txtTelefon") 46 | self.txtEmail = QtWidgets.QLineEdit(self.centralwidget) 47 | self.txtEmail.setGeometry(QtCore.QRect(220, 270, 311, 41)) 48 | self.txtEmail.setObjectName("txtEmail") 49 | self.lblID = QtWidgets.QLabel(self.centralwidget) 50 | self.lblID.setGeometry(QtCore.QRect(10, 20, 201, 41)) 51 | self.lblID.setObjectName("lblID") 52 | self.lblISIM = QtWidgets.QLabel(self.centralwidget) 53 | self.lblISIM.setGeometry(QtCore.QRect(10, 70, 201, 41)) 54 | self.lblISIM.setObjectName("lblISIM") 55 | self.lblSoyisim = QtWidgets.QLabel(self.centralwidget) 56 | self.lblSoyisim.setGeometry(QtCore.QRect(10, 120, 201, 41)) 57 | self.lblSoyisim.setObjectName("lblSoyisim") 58 | self.lblSehir = QtWidgets.QLabel(self.centralwidget) 59 | self.lblSehir.setGeometry(QtCore.QRect(10, 170, 201, 41)) 60 | self.lblSehir.setObjectName("lblSehir") 61 | self.lblTelefon = QtWidgets.QLabel(self.centralwidget) 62 | self.lblTelefon.setGeometry(QtCore.QRect(10, 220, 201, 41)) 63 | self.lblTelefon.setObjectName("lblTelefon") 64 | self.lblEmail = QtWidgets.QLabel(self.centralwidget) 65 | self.lblEmail.setGeometry(QtCore.QRect(10, 270, 201, 41)) 66 | self.lblEmail.setObjectName("lblEmail") 67 | self.tblListele = QtWidgets.QTableWidget(self.centralwidget) 68 | self.tblListele.setGeometry(QtCore.QRect(10, 330, 891, 341)) 69 | self.tblListele.setObjectName("tblListele") 70 | self.tblListele.setColumnCount(0) 71 | self.tblListele.setRowCount(0) 72 | MainWindow.setCentralWidget(self.centralwidget) 73 | self.menubar = QtWidgets.QMenuBar(MainWindow) 74 | self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 22)) 75 | self.menubar.setObjectName("menubar") 76 | MainWindow.setMenuBar(self.menubar) 77 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 78 | self.statusbar.setObjectName("statusbar") 79 | MainWindow.setStatusBar(self.statusbar) 80 | 81 | self.retranslateUi(MainWindow) 82 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 83 | 84 | def retranslateUi(self, MainWindow): 85 | _translate = QtCore.QCoreApplication.translate 86 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 87 | self.btnKaydet.setText(_translate("MainWindow", "KAYDET")) 88 | self.btnSil.setText(_translate("MainWindow", "SIL")) 89 | self.btnGuncelle.setText(_translate("MainWindow", "GUNCELLE")) 90 | self.btnListele.setText(_translate("MainWindow", "LISTELE")) 91 | self.lblID.setText(_translate("MainWindow", "ID")) 92 | self.lblISIM.setText(_translate("MainWindow", "ISIM")) 93 | self.lblSoyisim.setText(_translate("MainWindow", "SOYISIM")) 94 | self.lblSehir.setText(_translate("MainWindow", "SEHIR")) 95 | self.lblTelefon.setText(_translate("MainWindow", "TELEFON")) 96 | self.lblEmail.setText(_translate("MainWindow", "EMAIL")) 97 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/intro/Ui_TelefonDefteriGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'd:\pyqt5\QT-Designer-Examples\deneme\TelefonDefteriGUI.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(910, 723) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnKaydet = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnKaydet.setGeometry(QtCore.QRect(560, 20, 211, 41)) 21 | self.btnKaydet.setObjectName("btnKaydet") 22 | self.btnSil = QtWidgets.QPushButton(self.centralwidget) 23 | self.btnSil.setGeometry(QtCore.QRect(560, 70, 211, 41)) 24 | self.btnSil.setObjectName("btnSil") 25 | self.btnGuncelle = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGuncelle.setGeometry(QtCore.QRect(560, 120, 211, 41)) 27 | self.btnGuncelle.setObjectName("btnGuncelle") 28 | self.btnListele = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnListele.setGeometry(QtCore.QRect(560, 170, 211, 41)) 30 | self.btnListele.setObjectName("btnListele") 31 | self.txtID = QtWidgets.QLineEdit(self.centralwidget) 32 | self.txtID.setGeometry(QtCore.QRect(220, 20, 311, 41)) 33 | self.txtID.setObjectName("txtID") 34 | self.txtIsim = QtWidgets.QLineEdit(self.centralwidget) 35 | self.txtIsim.setGeometry(QtCore.QRect(220, 70, 311, 41)) 36 | self.txtIsim.setObjectName("txtIsim") 37 | self.txtSoyisim = QtWidgets.QLineEdit(self.centralwidget) 38 | self.txtSoyisim.setGeometry(QtCore.QRect(220, 120, 311, 41)) 39 | self.txtSoyisim.setObjectName("txtSoyisim") 40 | self.txtSehir = QtWidgets.QLineEdit(self.centralwidget) 41 | self.txtSehir.setGeometry(QtCore.QRect(220, 170, 311, 41)) 42 | self.txtSehir.setObjectName("txtSehir") 43 | self.txtTelefon = QtWidgets.QLineEdit(self.centralwidget) 44 | self.txtTelefon.setGeometry(QtCore.QRect(220, 220, 311, 41)) 45 | self.txtTelefon.setObjectName("txtTelefon") 46 | self.txtEmail = QtWidgets.QLineEdit(self.centralwidget) 47 | self.txtEmail.setGeometry(QtCore.QRect(220, 270, 311, 41)) 48 | self.txtEmail.setObjectName("txtEmail") 49 | self.lblID = QtWidgets.QLabel(self.centralwidget) 50 | self.lblID.setGeometry(QtCore.QRect(10, 20, 201, 41)) 51 | self.lblID.setObjectName("lblID") 52 | self.lblISIM = QtWidgets.QLabel(self.centralwidget) 53 | self.lblISIM.setGeometry(QtCore.QRect(10, 70, 201, 41)) 54 | self.lblISIM.setObjectName("lblISIM") 55 | self.lblSoyisim = QtWidgets.QLabel(self.centralwidget) 56 | self.lblSoyisim.setGeometry(QtCore.QRect(10, 120, 201, 41)) 57 | self.lblSoyisim.setObjectName("lblSoyisim") 58 | self.lblSehir = QtWidgets.QLabel(self.centralwidget) 59 | self.lblSehir.setGeometry(QtCore.QRect(10, 170, 201, 41)) 60 | self.lblSehir.setObjectName("lblSehir") 61 | self.lblTelefon = QtWidgets.QLabel(self.centralwidget) 62 | self.lblTelefon.setGeometry(QtCore.QRect(10, 220, 201, 41)) 63 | self.lblTelefon.setObjectName("lblTelefon") 64 | self.lblEmail = QtWidgets.QLabel(self.centralwidget) 65 | self.lblEmail.setGeometry(QtCore.QRect(10, 270, 201, 41)) 66 | self.lblEmail.setObjectName("lblEmail") 67 | self.tblListele = QtWidgets.QTableWidget(self.centralwidget) 68 | self.tblListele.setGeometry(QtCore.QRect(10, 330, 891, 341)) 69 | self.tblListele.setObjectName("tblListele") 70 | self.tblListele.setColumnCount(0) 71 | self.tblListele.setRowCount(0) 72 | MainWindow.setCentralWidget(self.centralwidget) 73 | self.menubar = QtWidgets.QMenuBar(MainWindow) 74 | self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 22)) 75 | self.menubar.setObjectName("menubar") 76 | MainWindow.setMenuBar(self.menubar) 77 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 78 | self.statusbar.setObjectName("statusbar") 79 | MainWindow.setStatusBar(self.statusbar) 80 | 81 | self.retranslateUi(MainWindow) 82 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 83 | 84 | def retranslateUi(self, MainWindow): 85 | _translate = QtCore.QCoreApplication.translate 86 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 87 | self.btnKaydet.setText(_translate("MainWindow", "KAYDET")) 88 | self.btnSil.setText(_translate("MainWindow", "SIL")) 89 | self.btnGuncelle.setText(_translate("MainWindow", "GUNCELLE")) 90 | self.btnListele.setText(_translate("MainWindow", "LISTELE")) 91 | self.lblID.setText(_translate("MainWindow", "ID")) 92 | self.lblISIM.setText(_translate("MainWindow", "ISIM")) 93 | self.lblSoyisim.setText(_translate("MainWindow", "SOYISIM")) 94 | self.lblSehir.setText(_translate("MainWindow", "SEHIR")) 95 | self.lblTelefon.setText(_translate("MainWindow", "TELEFON")) 96 | self.lblEmail.setText(_translate("MainWindow", "EMAIL")) 97 | -------------------------------------------------------------------------------- /Codes/02-QT-Designer-Examples/intro/deneme.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QWidget, QApplication, QLineEdit, QPushButton, QLabel 3 | 4 | class Pencere(QWidget): 5 | def __init__(self): 6 | super().__init__() 7 | self.ozellikEkle() 8 | self.ekOzellikEkle() 9 | self.buton.clicked.connect(self.tiklandi) 10 | 11 | def ozellikEkle(self): 12 | self.resize(500, 500) 13 | self.move(700, 100) 14 | self.setWindowTitle('Pencere') 15 | 16 | def ekOzellikEkle(self): 17 | self.input = QLineEdit("Bir Şey Yaz", self) 18 | self.input.setGeometry(10, 10, 200, 25) 19 | 20 | self.buton = QPushButton("Ekrana Yaz", self) 21 | self.buton.setGeometry(10, 50, 200, 75) 22 | 23 | self.label = QLabel("Sonuc", self) 24 | self.label.setGeometry(10, 110, 200, 75) 25 | 26 | def tiklandi(self): 27 | self.label.setText("Sonuc : " + self.input.text()) 28 | 29 | app = QApplication(sys.argv) 30 | pencere = Pencere() 31 | pencere.show() 32 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/Connection.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | print("Database created") 7 | except: 8 | print("failed to create database") 9 | finally: 10 | db.close() 11 | 12 | if __name__ == "__main__": 13 | main() -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/CreateTable.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | cur = db.cursor() 7 | tablequery = "CREATE TABLE Kullanicilar (id INT, isim TEXT, soyisim TEXT, sehir TEXT, telefon TEXT, email TEXT)" 8 | 9 | cur.execute(tablequery) 10 | print("Table Created Succesfully") 11 | 12 | except sql.Error as e: 13 | print("There is a table or an error has occurred") 14 | 15 | finally: 16 | db.close() 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/KullaniciArayuzu.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | from PyQt5.QtWidgets import QTableWidgetItem 3 | from TelefonDefteriGUI import Ui_MainWindow 4 | import sys 5 | import sqlite3 as sql 6 | import os 7 | os.system('python Connection.py') 8 | os.system('python CreateTable.py') 9 | 10 | global id, isim, soyisim, sehir, telefon, email 11 | 12 | # Kullanicilar tablosunun alanlari (id INT, isim TEXT, soyisim TEXT, sehir TEXT, telefon TEXT, email TEXT) 13 | 14 | class Window(QtWidgets.QMainWindow): 15 | def __init__(self): 16 | super(Window, self).__init__() 17 | self.ui = Ui_MainWindow() 18 | self.ui.setupUi(self) 19 | 20 | self.btnListeleClick() 21 | self.ui.btnListele.clicked.connect(self.btnListeleClick) 22 | self.ui.btnKaydet.clicked.connect(self.btnKaydetClick) 23 | self.ui.btnSil.clicked.connect(self.btnSilClick) 24 | self.ui.btnGuncelle.clicked.connect(self.btnGuncelleClick) 25 | self.ui.tblListele.clicked.connect(self.ListOnClick) 26 | 27 | def btnTemizle(self): 28 | self.ui.txtID.clear() 29 | self.ui.txtIsim.clear() 30 | self.ui.txtSoyisim.clear() 31 | self.ui.txtSehir.clear() 32 | self.ui.txtTelefon.clear() 33 | self.ui.txtEmail.clear() 34 | 35 | def ListOnClick(self): 36 | self.ui.txtID.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 0).text()) 37 | self.ui.txtIsim.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 1).text()) 38 | self.ui.txtSoyisim.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 2).text()) 39 | self.ui.txtSehir.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 3).text()) 40 | self.ui.txtTelefon.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 4).text()) 41 | self.ui.txtEmail.setText(self.ui.tblListele.item(self.ui.tblListele.currentRow(), 5).text()) 42 | 43 | def btnKaydetClick(self): 44 | id = self.ui.txtID.text() 45 | isim = self.ui.txtIsim.text() 46 | soyisim = self.ui.txtSoyisim.text() 47 | sehir = self.ui.txtSehir.text() 48 | telefon = self.ui.txtTelefon.text() 49 | email = self.ui.txtEmail.text() 50 | 51 | try: 52 | self.conn = sql.connect("TelefonDefteri.db") 53 | self.c = self.conn.cursor() 54 | self.c.execute("INSERT INTO Kullanicilar VALUES (?,?,?,?,?,?)",(id,isim,soyisim,sehir,telefon,email)) 55 | self.conn.commit() 56 | self.c.close() 57 | self.conn.close() 58 | print('Successful','User is added successfully to the database.') 59 | except Exception: 60 | print('Error', 'Could not add student to the database.') 61 | 62 | self.btnTemizle() 63 | self.btnListeleClick() 64 | 65 | def btnListeleClick(self): 66 | self.ui.tblListele.clear() 67 | self.ui.tblListele.setColumnCount(6) 68 | self.ui.tblListele.setHorizontalHeaderLabels(('ID','Isim','Soyisim','Sehir','Telefon','Email')) 69 | self.ui.tblListele.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch) 70 | db = sql.connect('TelefonDefteri.db') 71 | cur = db.cursor() 72 | selectquery = "SELECT * FROM Kullanicilar" 73 | cur.execute(selectquery) 74 | rows = cur.fetchall() 75 | 76 | self.ui.tblListele.setRowCount(len(rows)) 77 | 78 | for satirIndeks, satirVeri in enumerate(rows): 79 | for sutunIndeks, sutunVeri in enumerate (satirVeri): 80 | self.ui.tblListele.setItem(satirIndeks,sutunIndeks,QTableWidgetItem(str(sutunVeri))) 81 | 82 | def btnGuncelleClick(self): 83 | id = self.ui.txtID.text() 84 | isim = self.ui.txtIsim.text() 85 | soyisim = self.ui.txtSoyisim.text() 86 | sehir = self.ui.txtSehir.text() 87 | telefon = self.ui.txtTelefon.text() 88 | email = self.ui.txtEmail.text() 89 | 90 | try: 91 | self.conn = sql.connect("TelefonDefteri.db") 92 | self.c = self.conn.cursor() 93 | self.c.execute("UPDATE Kullanicilar SET isim = ?, soyisim = ?, sehir = ?, \ 94 | telefon = ?, email = ? WHERE id = ?",(isim,soyisim,sehir,telefon,email,id)) 95 | self.conn.commit() 96 | self.c.close() 97 | self.conn.close() 98 | print('Successful','User is updated successfully to the database.') 99 | except Exception: 100 | print('Error', 'Could not update student to the database.') 101 | 102 | self.btnTemizle() 103 | self.btnListeleClick() 104 | 105 | def btnSilClick(self): 106 | id = self.ui.txtID.text() 107 | 108 | try: 109 | self.conn = sql.connect("TelefonDefteri.db") 110 | self.c = self.conn.cursor() 111 | self.c.execute('DELETE FROM Kullanicilar WHERE id = ? ', (id,)) 112 | self.conn.commit() 113 | self.c.close() 114 | self.conn.close() 115 | print('Successful','User is deleted successfully from the database.') 116 | except Exception: 117 | print('Error', 'Could not delete student to the database.') 118 | 119 | self.btnTemizle() 120 | self.btnListeleClick() 121 | 122 | 123 | def app(): 124 | app = QtWidgets.QApplication(sys.argv) 125 | win = Window() 126 | win.show() 127 | sys.exit(app.exec_()) 128 | 129 | app() -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Sevdanur GENC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/README.md: -------------------------------------------------------------------------------- 1 | # PyQt5-SqLite-Crud-Project 2 | 3 | For the visual programming course, it was connected to the database with SQLite using the PyQT5 user interface and CRUD operations were performed. 4 | 5 | ![image](https://user-images.githubusercontent.com/5441882/94076479-df211400-fe05-11ea-82a8-8ef79ddcb9e9.png) 6 | 7 | ![image](https://user-images.githubusercontent.com/5441882/94076101-12af6e80-fe05-11ea-9cb7-05a1361d89ce.png) 8 | -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/TelefonDefteri.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/03-PyQt5-SQLite-CRUD-Project/TelefonDefteri.db -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/TelefonDefteriGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'TelefonDefteriGUI.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(910, 723) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnKaydet = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnKaydet.setGeometry(QtCore.QRect(560, 20, 211, 41)) 21 | self.btnKaydet.setObjectName("btnKaydet") 22 | self.btnSil = QtWidgets.QPushButton(self.centralwidget) 23 | self.btnSil.setGeometry(QtCore.QRect(560, 70, 211, 41)) 24 | self.btnSil.setObjectName("btnSil") 25 | self.btnGuncelle = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGuncelle.setGeometry(QtCore.QRect(560, 120, 211, 41)) 27 | self.btnGuncelle.setObjectName("btnGuncelle") 28 | self.btnListele = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnListele.setGeometry(QtCore.QRect(560, 170, 211, 41)) 30 | self.btnListele.setObjectName("btnListele") 31 | self.txtID = QtWidgets.QLineEdit(self.centralwidget) 32 | self.txtID.setGeometry(QtCore.QRect(220, 20, 311, 41)) 33 | self.txtID.setObjectName("txtID") 34 | self.txtIsim = QtWidgets.QLineEdit(self.centralwidget) 35 | self.txtIsim.setGeometry(QtCore.QRect(220, 70, 311, 41)) 36 | self.txtIsim.setObjectName("txtIsim") 37 | self.txtSoyisim = QtWidgets.QLineEdit(self.centralwidget) 38 | self.txtSoyisim.setGeometry(QtCore.QRect(220, 120, 311, 41)) 39 | self.txtSoyisim.setObjectName("txtSoyisim") 40 | self.txtSehir = QtWidgets.QLineEdit(self.centralwidget) 41 | self.txtSehir.setGeometry(QtCore.QRect(220, 170, 311, 41)) 42 | self.txtSehir.setObjectName("txtSehir") 43 | self.txtTelefon = QtWidgets.QLineEdit(self.centralwidget) 44 | self.txtTelefon.setGeometry(QtCore.QRect(220, 220, 311, 41)) 45 | self.txtTelefon.setObjectName("txtTelefon") 46 | self.txtEmail = QtWidgets.QLineEdit(self.centralwidget) 47 | self.txtEmail.setGeometry(QtCore.QRect(220, 270, 311, 41)) 48 | self.txtEmail.setObjectName("txtEmail") 49 | self.lblID = QtWidgets.QLabel(self.centralwidget) 50 | self.lblID.setGeometry(QtCore.QRect(10, 20, 201, 41)) 51 | self.lblID.setObjectName("lblID") 52 | self.lblISIM = QtWidgets.QLabel(self.centralwidget) 53 | self.lblISIM.setGeometry(QtCore.QRect(10, 70, 201, 41)) 54 | self.lblISIM.setObjectName("lblISIM") 55 | self.lblSoyisim = QtWidgets.QLabel(self.centralwidget) 56 | self.lblSoyisim.setGeometry(QtCore.QRect(10, 120, 201, 41)) 57 | self.lblSoyisim.setObjectName("lblSoyisim") 58 | self.lblSehir = QtWidgets.QLabel(self.centralwidget) 59 | self.lblSehir.setGeometry(QtCore.QRect(10, 170, 201, 41)) 60 | self.lblSehir.setObjectName("lblSehir") 61 | self.lblTelefon = QtWidgets.QLabel(self.centralwidget) 62 | self.lblTelefon.setGeometry(QtCore.QRect(10, 220, 201, 41)) 63 | self.lblTelefon.setObjectName("lblTelefon") 64 | self.lblEmail = QtWidgets.QLabel(self.centralwidget) 65 | self.lblEmail.setGeometry(QtCore.QRect(10, 270, 201, 41)) 66 | self.lblEmail.setObjectName("lblEmail") 67 | self.tblListele = QtWidgets.QTableWidget(self.centralwidget) 68 | self.tblListele.setGeometry(QtCore.QRect(10, 330, 891, 341)) 69 | self.tblListele.setObjectName("tblListele") 70 | self.tblListele.setColumnCount(0) 71 | self.tblListele.setRowCount(0) 72 | MainWindow.setCentralWidget(self.centralwidget) 73 | self.menubar = QtWidgets.QMenuBar(MainWindow) 74 | self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 22)) 75 | self.menubar.setObjectName("menubar") 76 | MainWindow.setMenuBar(self.menubar) 77 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 78 | self.statusbar.setObjectName("statusbar") 79 | MainWindow.setStatusBar(self.statusbar) 80 | 81 | self.retranslateUi(MainWindow) 82 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 83 | 84 | def retranslateUi(self, MainWindow): 85 | _translate = QtCore.QCoreApplication.translate 86 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 87 | self.btnKaydet.setText(_translate("MainWindow", "KAYDET")) 88 | self.btnSil.setText(_translate("MainWindow", "SIL")) 89 | self.btnGuncelle.setText(_translate("MainWindow", "GUNCELLE")) 90 | self.btnListele.setText(_translate("MainWindow", "LISTELE")) 91 | self.lblID.setText(_translate("MainWindow", "ID")) 92 | self.lblISIM.setText(_translate("MainWindow", "ISIM")) 93 | self.lblSoyisim.setText(_translate("MainWindow", "SOYISIM")) 94 | self.lblSehir.setText(_translate("MainWindow", "SEHIR")) 95 | self.lblTelefon.setText(_translate("MainWindow", "TELEFON")) 96 | self.lblEmail.setText(_translate("MainWindow", "EMAIL")) 97 | -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/Connection.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/Connection.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/TelefonDefteriGUI.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/TelefonDefteriGUI.cpython-37.pyc -------------------------------------------------------------------------------- /Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/TelefonDefteriGUI.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/03-PyQt5-SQLite-CRUD-Project/__pycache__/TelefonDefteriGUI.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/Dial.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | self.dial = QDial() 10 | self.dial.setMinimum(0) 11 | self.dial.setMaximum(100) 12 | self.dial.setValue(40) 13 | self.dial.valueChanged.connect(self.sliderMoved) 14 | layout.addWidget(self.dial) 15 | 16 | def sliderMoved(self): 17 | print("Dial value = %i" % (self.dial.value())) 18 | 19 | app = QApplication(sys.argv) 20 | screen = Window() 21 | screen.show() 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/Pixmap.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QGridLayout, QWidget 3 | from PyQt5.QtGui import QPixmap 4 | 5 | class Example(QWidget): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | 10 | self.im = QPixmap("./images/icon.png") 11 | self.label = QLabel() 12 | self.label.setPixmap(self.im) 13 | 14 | self.grid = QGridLayout() 15 | self.grid.addWidget(self.label,1,1) 16 | self.setLayout(self.grid) 17 | 18 | self.setGeometry(50,50,320,200) 19 | self.setWindowTitle("PyQT show image") 20 | self.show() 21 | 22 | if __name__ == '__main__': 23 | app = QApplication(sys.argv) 24 | ex = Example() 25 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/Progressbar.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtCore import QTimer 3 | from PyQt5.QtWidgets import QApplication, QMainWindow, QProgressBar 4 | from PyQt5.QtCore import Qt 5 | 6 | class Example(QMainWindow): 7 | 8 | def __init__(self): 9 | super().__init__() 10 | 11 | self.pbar = QProgressBar(self) 12 | self.pbar.setGeometry(30, 40, 200, 25) 13 | self.pbar.setValue(50) 14 | 15 | self.setWindowTitle("QT Progressbar Example") 16 | self.setGeometry(32,32,320,200) 17 | self.show() 18 | 19 | self.timer = QTimer() 20 | self.timer.timeout.connect(self.handleTimer) 21 | self.timer.start(1000) 22 | 23 | def handleTimer(self): 24 | value = self.pbar.value() 25 | if value < 100: 26 | value = value + 1 27 | self.pbar.setValue(value) 28 | else: 29 | self.timer.stop() 30 | 31 | 32 | if __name__ == '__main__': 33 | app = QApplication(sys.argv) 34 | ex = Example() 35 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/Slider.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QSlider 3 | from PyQt5.QtCore import Qt 4 | 5 | class Example(QMainWindow): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | 10 | mySlider = QSlider(Qt.Horizontal, self) 11 | mySlider.setGeometry(30, 40, 200, 30) 12 | mySlider.valueChanged[int].connect(self.changeValue) 13 | 14 | self.setGeometry(50,50,320,200) 15 | self.setWindowTitle("QSlider Example") 16 | self.show() 17 | 18 | def changeValue(self, value): 19 | print(value) 20 | 21 | if __name__ == '__main__': 22 | app = QApplication(sys.argv) 23 | ex = Example() 24 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/ToolBox01.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # Add toolbar and items 12 | toolbox = QToolBox() 13 | layout.addWidget(toolbox, 0, 0) 14 | label = QLabel() 15 | toolbox.addItem(label, "Students") 16 | label = QLabel() 17 | toolbox.addItem(label, "Teachers") 18 | label = QLabel() 19 | toolbox.addItem(label, "Directors") 20 | 21 | app = QApplication(sys.argv) 22 | screen = Window() 23 | screen.show() 24 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/ToolBox02.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # Add toolbar and items 12 | toolbox = QToolBox() 13 | layout.addWidget(toolbox, 0, 0) 14 | label = QLabel() 15 | toolbox.addItem(label, "Students") 16 | label = QLabel() 17 | toolbox.addItem(label, "Teachers") 18 | label = QLabel() 19 | toolbox.addItem(label, "Directors") 20 | 21 | # show number of items 22 | print(toolbox.count()) 23 | 24 | # disable tab 25 | toolbox.setItemEnabled(0, False) 26 | 27 | # mouseover tooltip 28 | toolbox.setItemToolTip(0, "This is a tooltip") 29 | 30 | # tests if items are enabled 31 | print(toolbox.isItemEnabled(0)) 32 | print(toolbox.isItemEnabled(1)) 33 | 34 | # insert item 35 | item = QLabel() 36 | toolbox.insertItem(1, item, "Python") 37 | 38 | app = QApplication(sys.argv) 39 | screen = Window() 40 | screen.show() 41 | sys.exit(app.exec_()) 42 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/autoComplete.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | 10 | # auto complete options 11 | names = ["Apple", "Alps", "Berry", "Cherry" ] 12 | completer = QCompleter(names) 13 | 14 | # create line edit and add auto complete 15 | self.lineedit = QLineEdit() 16 | self.lineedit.setCompleter(completer) 17 | layout.addWidget(self.lineedit, 0, 0) 18 | 19 | app = QApplication(sys.argv) 20 | screen = Window() 21 | screen.show() 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/altincihafta/images/icon.png -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/altincihafta/listBox.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | self.listwidget = QListWidget() 10 | self.listwidget.insertItem(0, "Red") 11 | self.listwidget.insertItem(1, "Orange") 12 | self.listwidget.insertItem(2, "Blue") 13 | self.listwidget.insertItem(3, "White") 14 | self.listwidget.insertItem(4, "Green") 15 | self.listwidget.clicked.connect(self.clicked) 16 | layout.addWidget(self.listwidget) 17 | 18 | def clicked(self, qmodelindex): 19 | item = self.listwidget.currentItem() 20 | print(item.text()) 21 | 22 | app = QApplication(sys.argv) 23 | screen = Window() 24 | screen.show() 25 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/besincihafta/TabWidget.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtWidgets import * 3 | import sys 4 | 5 | class Window(QWidget): 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | label1 = QLabel("Widget in Tab 1.") 11 | label2 = QLabel("Widget in Tab 2.") 12 | tabwidget = QTabWidget() 13 | tabwidget.addTab(label1, "Tab 1") 14 | tabwidget.addTab(label2, "Tab 2") 15 | layout.addWidget(tabwidget, 0, 0) 16 | 17 | app = QApplication(sys.argv) 18 | screen = Window() 19 | screen.show() 20 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/besincihafta/inputDialog.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import (QWidget, QPushButton, QInputDialog, QApplication, QLabel) 2 | import sys 3 | 4 | class Example(QWidget): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | self.initUI() 9 | 10 | def initUI(self): 11 | # Add button 12 | self.btn = QPushButton('Show Input Dialog', self) 13 | self.btn.move(30, 20) 14 | self.btn.clicked.connect(self.showDialog) 15 | 16 | # Add label 17 | self.le = QLabel(self) 18 | self.le.move(30, 62) 19 | self.le.resize(400,22) 20 | 21 | self.setGeometry(300, 300, 290, 150) 22 | self.setWindowTitle('Input dialog') 23 | self.show() 24 | 25 | 26 | def showDialog(self): 27 | text, ok = QInputDialog.getText(self, 'Input Dialog', 'Enter text:') 28 | if ok: 29 | self.le.setText(str(text)) 30 | 31 | if __name__ == '__main__': 32 | app = QApplication(sys.argv) 33 | ex = Example() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/besincihafta/menubar.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtCore import * 2 | from PyQt5.QtWidgets import * 3 | import sys 4 | 5 | class Window(QWidget): 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | layout = QGridLayout() 9 | self.setLayout(layout) 10 | 11 | # create menu 12 | menubar = QMenuBar() 13 | layout.addWidget(menubar, 0, 0) 14 | actionFile = menubar.addMenu("File") 15 | actionFile.addAction("New") 16 | actionFile.addAction("Open") 17 | actionFile.addAction("Save") 18 | actionFile.addSeparator() 19 | actionFile.addAction("Quit") 20 | menubar.addMenu("Edit") 21 | menubar.addMenu("View") 22 | menubar.addMenu("Help") 23 | 24 | # add textbox 25 | tbox = QPlainTextEdit() 26 | layout.addWidget(tbox, 1, 0) 27 | 28 | app = QApplication(sys.argv) 29 | screen = Window() 30 | screen.show() 31 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/besincihafta/tables.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QTableWidget, QTableWidgetItem 2 | import sys 3 | 4 | data = {'col1':['1','2','3','4'], 5 | 'col2':['1','2','1','3'], 6 | 'col3':['1','1','2','1']} 7 | 8 | class TableView(QTableWidget): 9 | def __init__(self, data, *args): 10 | QTableWidget.__init__(self, *args) 11 | self.data = data 12 | self.setData() 13 | self.resizeColumnsToContents() 14 | self.resizeRowsToContents() 15 | 16 | def setData(self): 17 | horHeaders = [] 18 | for n, key in enumerate(sorted(self.data.keys())): 19 | horHeaders.append(key) 20 | for m, item in enumerate(self.data[key]): 21 | newitem = QTableWidgetItem(item) 22 | self.setItem(m, n, newitem) 23 | self.setHorizontalHeaderLabels(horHeaders) 24 | 25 | def main(args): 26 | app = QApplication(args) 27 | table = TableView(data, 4, 3) 28 | table.show() 29 | sys.exit(app.exec_()) 30 | 31 | if __name__=="__main__": 32 | main(sys.argv) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/besincihafta/twoWindow.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtGui 3 | from PyQt5.QtWidgets import (QApplication, QMainWindow, QPushButton, QLabel) 4 | 5 | class Window2(QMainWindow): 6 | def __init__(self): 7 | super().__init__() 8 | self.setWindowTitle("Window22222") 9 | 10 | class Window(QMainWindow): 11 | def __init__(self): 12 | super().__init__() 13 | 14 | self.title = "First Window" 15 | self.top = 100 16 | self.left = 100 17 | self.width = 680 18 | self.height = 500 19 | 20 | self.pushButton = QPushButton("Start", self) 21 | self.pushButton.move(275, 200) 22 | self.pushButton.setToolTip("

Start the Session

") 23 | 24 | self.pushButton.clicked.connect(self.window2) 25 | 26 | self.main_window() 27 | 28 | def main_window(self): 29 | self.label = QLabel("Manager", self) 30 | self.label.move(285, 175) 31 | self.setWindowTitle(self.title) 32 | self.setGeometry(self.top, self.left, self.width, self.height) 33 | self.show() 34 | 35 | def window2(self): 36 | self.w = Window2() 37 | self.w.show() 38 | self.hide() 39 | 40 | if __name__ == "__main__": 41 | app = QApplication(sys.argv) 42 | window = Window() 43 | sys.exit(app.exec()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/GroupBox..py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class GroupBox(QWidget): 5 | 6 | def __init__(self): 7 | QWidget.__init__(self) 8 | 9 | self.setWindowTitle("GroupBox") 10 | layout = QGridLayout() 11 | self.setLayout(layout) 12 | 13 | groupbox = QGroupBox("GroupBox Example") 14 | groupbox.setCheckable(True) 15 | layout.addWidget(groupbox) 16 | 17 | vbox = QVBoxLayout() 18 | groupbox.setLayout(vbox) 19 | 20 | radiobutton = QRadioButton("RadioButton 1") 21 | vbox.addWidget(radiobutton) 22 | 23 | radiobutton = QRadioButton("RadioButton 2") 24 | vbox.addWidget(radiobutton) 25 | 26 | radiobutton = QRadioButton("RadioButton 3") 27 | vbox.addWidget(radiobutton) 28 | 29 | radiobutton = QRadioButton("RadioButton 4") 30 | vbox.addWidget(radiobutton) 31 | 32 | 33 | app = QApplication(sys.argv) 34 | screen = GroupBox() 35 | screen.show() 36 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/QMessageBox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QMessageBox 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QWidget() 9 | button1 = QPushButton(win) 10 | button1.setText("Show dialog!") 11 | button1.move(50,50) 12 | button1.clicked.connect(showDialog) 13 | win.setWindowTitle("Click button") 14 | win.show() 15 | sys.exit(app.exec_()) 16 | 17 | def showDialog(): 18 | msgBox = QMessageBox() 19 | msgBox.setIcon(QMessageBox.Information) 20 | msgBox.setText("Message box pop up window") 21 | msgBox.setWindowTitle("QMessageBox Example") 22 | msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) 23 | msgBox.buttonClicked.connect(msgButtonClick) 24 | 25 | returnValue = msgBox.exec() 26 | if returnValue == QMessageBox.Ok: 27 | print('OK clicked') 28 | 29 | def msgButtonClick(i): 30 | print("Button clicked is:",i.text()) 31 | 32 | if __name__ == '__main__': 33 | window() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/layout/QGridLayout.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QGridLayout, QPushButton 3 | from PyQt5.QtGui import QIcon 4 | from PyQt5.QtCore import pyqtSlot 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QWidget() 9 | grid = QGridLayout() 10 | 11 | for i in range(0,5): 12 | for j in range(0,5): 13 | grid.addWidget(QPushButton(str(i)+str(j)),i,j) 14 | 15 | win.setLayout(grid) 16 | win.setWindowTitle("PyQt Grid Example") 17 | win.setGeometry(50,50,200,200) 18 | win.show() 19 | sys.exit(app.exec_()) 20 | 21 | if __name__ == '__main__': 22 | window() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/layout/QVBoxLayout.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout 2 | 3 | app = QApplication([]) 4 | window = QWidget() 5 | layout = QVBoxLayout() 6 | layout.addWidget(QPushButton('1')) 7 | layout.addWidget(QPushButton('2')) 8 | layout.addWidget(QPushButton('3')) 9 | 10 | window.setLayout(layout) 11 | window.show() 12 | app.exec_() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/layout/layouts_.tekboyut.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | #layout = QtWidgets.QVBoxLayout() 21 | layout = QtWidgets.QHBoxLayout() 22 | 23 | layout.addWidget(Color('red')) 24 | layout.addWidget(Color('blue')) 25 | layout.addWidget(Color('green')) 26 | 27 | widget = QWidget() 28 | widget.setLayout(layout) 29 | 30 | self.setCentralWidget(widget) 31 | 32 | def app(): 33 | app = QApplication(sys.argv) 34 | win = MainWindow() 35 | win.show() 36 | sys.exit(app.exec_()) 37 | 38 | app() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/layout/layouts_ciftboyut.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | hlayout1 = QtWidgets.QHBoxLayout() 21 | hlayout1.addWidget(Color('red')) 22 | hlayout1.addWidget(Color('green')) 23 | hlayout1.addWidget(Color('blue')) 24 | 25 | hlayout2 = QtWidgets.QHBoxLayout() 26 | hlayout2.addWidget(Color('red')) 27 | hlayout2.addWidget(Color('blue')) 28 | 29 | vlayout = QtWidgets.QVBoxLayout() 30 | vlayout.addLayout(hlayout1) 31 | vlayout.addLayout(hlayout2) 32 | 33 | widget = QWidget() 34 | widget.setLayout(vlayout) 35 | 36 | self.setCentralWidget(widget) 37 | 38 | def app(): 39 | app = QApplication(sys.argv) 40 | win = MainWindow() 41 | win.show() 42 | sys.exit(app.exec_()) 43 | 44 | app() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/layout/layouts_grid.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow 4 | from PyQt5.QtGui import QPalette, QColor 5 | 6 | class Color(QWidget): 7 | def __init__(self, color): 8 | super(Color, self).__init__() 9 | self.setAutoFillBackground(True) 10 | 11 | palette = self.palette() 12 | palette.setColor(QPalette.Window, QColor(color)) 13 | self.setPalette(palette) 14 | 15 | class MainWindow(QMainWindow): 16 | def __init__(self): 17 | super(MainWindow, self).__init__() 18 | self.setGeometry(100,100,500,500) 19 | 20 | layout = QtWidgets.QGridLayout() 21 | 22 | layout.addWidget(Color('red'),0,0) 23 | layout.addWidget(Color('green'),1,0) 24 | layout.addWidget(Color('blue'),0,2) 25 | layout.addWidget(Color('pink'),3,1) 26 | 27 | widget = QWidget() 28 | widget.setLayout(layout) 29 | 30 | self.setCentralWidget(widget) 31 | 32 | def app(): 33 | app = QApplication(sys.argv) 34 | win = MainWindow() 35 | win.show() 36 | sys.exit(app.exec_()) 37 | 38 | app() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/dorduncuhafta/radiobutton.py: -------------------------------------------------------------------------------- 1 | from PyQt5.QtWidgets import * 2 | import sys 3 | 4 | class Window(QWidget): 5 | def __init__(self): 6 | QWidget.__init__(self) 7 | layout = QGridLayout() 8 | self.setLayout(layout) 9 | 10 | radiobutton = QRadioButton("Australia") 11 | radiobutton.setChecked(True) 12 | radiobutton.country = "Australia" 13 | radiobutton.toggled.connect(self.onClicked) 14 | layout.addWidget(radiobutton, 0, 0) 15 | 16 | radiobutton = QRadioButton("China") 17 | radiobutton.country = "China" 18 | radiobutton.toggled.connect(self.onClicked) 19 | layout.addWidget(radiobutton, 0, 1) 20 | 21 | radiobutton = QRadioButton("Japan") 22 | radiobutton.country = "Japan" 23 | radiobutton.toggled.connect(self.onClicked) 24 | layout.addWidget(radiobutton, 0, 2) 25 | 26 | def onClicked(self): 27 | radioButton = self.sender() 28 | if radioButton.isChecked(): 29 | print("Country is %s" % (radioButton.country)) 30 | 31 | app = QApplication(sys.argv) 32 | screen = Window() 33 | screen.show() 34 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ikincihafta/ekranayazdi.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip 4 | from PyQt5.QtGui import QIcon 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QMainWindow() 9 | 10 | win.setWindowTitle('Ilk Uygulama') 11 | win.setGeometry(200,200,500,500) 12 | win.setWindowIcon(QIcon('C:/Users/Nano/Desktop/pyqt-deneme/ikincihafta/icon.png')) 13 | win.setToolTip('Tooltip Mesaji') 14 | 15 | lbl_isim = QtWidgets.QLabel(win) 16 | lbl_isim.setText('Isminiz : ') 17 | lbl_isim.move(50,30) 18 | 19 | lbl_soyisim = QtWidgets.QLabel(win) 20 | lbl_soyisim.setText('Soyisminiz : ') 21 | lbl_soyisim.move(50,70) 22 | 23 | txt_isim = QtWidgets.QLineEdit(win) 24 | txt_isim.move(250, 30) 25 | 26 | txt_soyisim = QtWidgets.QLineEdit(win) 27 | txt_soyisim.move(250, 70) 28 | 29 | def clicked(self): 30 | print(txt_isim.text() + ' ' + txt_soyisim.text() + ' kisisi sisteme kaydedilmistir' ) 31 | 32 | btn_kaydet = QtWidgets.QPushButton(win) 33 | btn_kaydet.move(250, 110) 34 | btn_kaydet.setText('Kaydet') 35 | 36 | btn_kaydet.clicked.connect(clicked) 37 | 38 | win.show() #pencere gosteriliyor 39 | sys.exit(app.exec_()) #pencere kapatmak icin x iconu ekleniyor 40 | 41 | 42 | window() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ikincihafta/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/ikincihafta/icon.png -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ikincihafta/iconuygulamasi.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QApplication, QMainWindow, QToolTip 4 | from PyQt5.QtGui import QIcon 5 | 6 | def window(): 7 | app = QApplication(sys.argv) 8 | win = QMainWindow() 9 | 10 | win.setWindowTitle('Ilk Uygulama') 11 | win.setGeometry(200,200,500,500) 12 | win.setWindowIcon(QIcon('C:/Users/Nano/Desktop/pyqt-deneme/ikincihafta/icon.png')) 13 | win.setToolTip('Tooltip Mesaji') 14 | 15 | lbl_isim = QtWidgets.QLabel(win) 16 | lbl_isim.setText('Isminiz : ') 17 | lbl_isim.move(50,30) 18 | 19 | lbl_soyisim = QtWidgets.QLabel(win) 20 | lbl_soyisim.setText('Soyisminiz : ') 21 | lbl_soyisim.move(50,70) 22 | 23 | txt_isim = QtWidgets.QLineEdit(win) 24 | txt_isim.move(250, 30) 25 | 26 | txt_soyisim = QtWidgets.QLineEdit(win) 27 | txt_soyisim.move(250, 70) 28 | 29 | def clicked(self): 30 | print(txt_isim.text() + ' ' + txt_soyisim.text() + ' kisisi sisteme kaydedilmistir' ) 31 | 32 | btn_kaydet = QtWidgets.QPushButton(win) 33 | btn_kaydet.move(250, 110) 34 | btn_kaydet.setText('Kaydet') 35 | 36 | btn_kaydet.clicked.connect(clicked) 37 | 38 | 39 | 40 | win.show() #pencere gosteriliyor 41 | sys.exit(app.exec_()) #pencere kapatmak icin x iconu ekleniyor 42 | 43 | window() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/Ui_deneme.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'c:\Users\Nano\Desktop\pyqt-deneme\ilkhafta\deneme.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.15.11 6 | # 7 | # WARNING: Any manual changes made to this file will be lost when pyuic5 is 8 | # run again. Do not edit this file unless you know what you are doing. 9 | 10 | 11 | from PyQt5 import QtCore, QtGui, QtWidgets 12 | 13 | 14 | class Ui_Dialog(object): 15 | def setupUi(self, Dialog): 16 | Dialog.setObjectName("Dialog") 17 | Dialog.resize(400, 300) 18 | self.buttonBox = QtWidgets.QDialogButtonBox(Dialog) 19 | self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32)) 20 | self.buttonBox.setOrientation(QtCore.Qt.Horizontal) 21 | self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) 22 | self.buttonBox.setObjectName("buttonBox") 23 | self.pushButton = QtWidgets.QPushButton(Dialog) 24 | self.pushButton.setGeometry(QtCore.QRect(300, 210, 75, 23)) 25 | self.pushButton.setObjectName("pushButton") 26 | self.textBrowser = QtWidgets.QTextBrowser(Dialog) 27 | self.textBrowser.setGeometry(QtCore.QRect(20, 40, 256, 192)) 28 | self.textBrowser.setObjectName("textBrowser") 29 | self.label = QtWidgets.QLabel(Dialog) 30 | self.label.setGeometry(QtCore.QRect(30, 10, 47, 13)) 31 | self.label.setObjectName("label") 32 | 33 | self.retranslateUi(Dialog) 34 | self.buttonBox.accepted.connect(Dialog.accept) # type: ignore 35 | self.buttonBox.rejected.connect(Dialog.reject) # type: ignore 36 | QtCore.QMetaObject.connectSlotsByName(Dialog) 37 | 38 | def retranslateUi(self, Dialog): 39 | _translate = QtCore.QCoreApplication.translate 40 | Dialog.setWindowTitle(_translate("Dialog", "Dialog")) 41 | self.pushButton.setText(_translate("Dialog", "PushButton")) 42 | self.label.setText(_translate("Dialog", "TextLabel")) 43 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/deneme-cla.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QWidget, QApplication 3 | 4 | class Pencere(QWidget): 5 | def __init__(self): 6 | super().__init__() 7 | self.ozellikEkle() 8 | def ozellikEkle(self): 9 | self.resize(500, 500) 10 | self.move(700, 100) 11 | self.setWindowTitle('Pencere') 12 | 13 | app = QApplication(sys.argv) 14 | pencere = Pencere() 15 | pencere.show() 16 | sys.exit(app.exec_()) 17 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/deneme-win.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget 3 | 4 | app = QApplication(sys.argv) 5 | 6 | pencere = QWidget() 7 | pencere.resize(500, 500) 8 | pencere.move(700, 100) 9 | pencere.setWindowTitle('Pencere') 10 | pencere.show() 11 | sys.exit(app.exec_()) 12 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/deneme.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 30 20 | 240 21 | 341 22 | 32 23 | 24 | 25 | 26 | Qt::Horizontal 27 | 28 | 29 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 30 | 31 | 32 | 33 | 34 | 35 | 300 36 | 210 37 | 75 38 | 23 39 | 40 | 41 | 42 | PushButton 43 | 44 | 45 | 46 | 47 | 48 | 20 49 | 40 50 | 256 51 | 192 52 | 53 | 54 | 55 | 56 | 57 | 58 | 30 59 | 10 60 | 47 61 | 13 62 | 63 | 64 | 65 | TextLabel 66 | 67 | 68 | 69 | 70 | 71 | 72 | buttonBox 73 | accepted() 74 | Dialog 75 | accept() 76 | 77 | 78 | 248 79 | 254 80 | 81 | 82 | 157 83 | 274 84 | 85 | 86 | 87 | 88 | buttonBox 89 | rejected() 90 | Dialog 91 | reject() 92 | 93 | 94 | 316 95 | 260 96 | 97 | 98 | 286 99 | 274 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/dialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 30 20 | 240 21 | 341 22 | 32 23 | 24 | 25 | 26 | Qt::Horizontal 27 | 28 | 29 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 30 | 31 | 32 | 33 | 34 | 35 | 300 36 | 210 37 | 75 38 | 23 39 | 40 | 41 | 42 | PushButton 43 | 44 | 45 | 46 | 47 | 48 | 20 49 | 40 50 | 256 51 | 192 52 | 53 | 54 | 55 | 56 | 57 | 58 | 30 59 | 10 60 | 47 61 | 13 62 | 63 | 64 | 65 | TextLabel 66 | 67 | 68 | 69 | 70 | 71 | 300 72 | 90 73 | 82 74 | 17 75 | 76 | 77 | 78 | RadioButton 79 | 80 | 81 | 82 | 83 | 84 | 85 | buttonBox 86 | accepted() 87 | Dialog 88 | accept() 89 | 90 | 91 | 248 92 | 254 93 | 94 | 95 | 157 96 | 274 97 | 98 | 99 | 100 | 101 | buttonBox 102 | rejected() 103 | Dialog 104 | reject() 105 | 106 | 107 | 316 108 | 260 109 | 110 | 111 | 286 112 | 274 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/helloworld.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QLabel 3 | 4 | def window(): 5 | app = QApplication(sys.argv) 6 | widget = QWidget() 7 | 8 | textLabel = QLabel(widget) 9 | textLabel.setText("Hello World!") 10 | textLabel.move(110,85) 11 | 12 | widget.setGeometry(150,150,320,200) 13 | widget.setWindowTitle("PyQt5 Example") 14 | widget.show() 15 | sys.exit(app.exec_()) 16 | 17 | if __name__ == '__main__': 18 | window() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ilkhafta/main.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import uic 2 | from PyQt5.QtWidgets import QApplication 3 | 4 | Form, Window = uic.loadUiType("dialog.ui") 5 | 6 | app = QApplication([]) 7 | window = Window() 8 | form = Form() 9 | form.setupUi(window) 10 | window.show() 11 | app.exec() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/sekizincihafta/MainWindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'MainWindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(495, 269) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.lbl_sayi1 = QtWidgets.QLabel(self.centralwidget) 20 | self.lbl_sayi1.setGeometry(QtCore.QRect(40, 60, 47, 14)) 21 | self.lbl_sayi1.setObjectName("lbl_sayi1") 22 | self.lbl_sayi2 = QtWidgets.QLabel(self.centralwidget) 23 | self.lbl_sayi2.setGeometry(QtCore.QRect(40, 90, 47, 14)) 24 | self.lbl_sayi2.setObjectName("lbl_sayi2") 25 | self.txt_sayi1 = QtWidgets.QLineEdit(self.centralwidget) 26 | self.txt_sayi1.setGeometry(QtCore.QRect(110, 60, 181, 20)) 27 | self.txt_sayi1.setObjectName("txt_sayi1") 28 | self.txt_sayi2 = QtWidgets.QLineEdit(self.centralwidget) 29 | self.txt_sayi2.setGeometry(QtCore.QRect(110, 90, 181, 20)) 30 | self.txt_sayi2.setObjectName("txt_sayi2") 31 | self.btn_topla = QtWidgets.QPushButton(self.centralwidget) 32 | self.btn_topla.setGeometry(QtCore.QRect(110, 130, 75, 23)) 33 | self.btn_topla.setObjectName("btn_topla") 34 | self.btn_cikarma = QtWidgets.QPushButton(self.centralwidget) 35 | self.btn_cikarma.setGeometry(QtCore.QRect(190, 130, 75, 23)) 36 | self.btn_cikarma.setObjectName("btn_cikarma") 37 | self.btn_carpma = QtWidgets.QPushButton(self.centralwidget) 38 | self.btn_carpma.setGeometry(QtCore.QRect(270, 130, 75, 23)) 39 | self.btn_carpma.setObjectName("btn_carpma") 40 | self.btn_bolme = QtWidgets.QPushButton(self.centralwidget) 41 | self.btn_bolme.setGeometry(QtCore.QRect(350, 130, 75, 23)) 42 | self.btn_bolme.setObjectName("btn_bolme") 43 | self.lbl_sonuc = QtWidgets.QLabel(self.centralwidget) 44 | self.lbl_sonuc.setGeometry(QtCore.QRect(110, 180, 301, 31)) 45 | self.lbl_sonuc.setObjectName("lbl_sonuc") 46 | MainWindow.setCentralWidget(self.centralwidget) 47 | self.menubar = QtWidgets.QMenuBar(MainWindow) 48 | self.menubar.setGeometry(QtCore.QRect(0, 0, 495, 22)) 49 | self.menubar.setObjectName("menubar") 50 | MainWindow.setMenuBar(self.menubar) 51 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 52 | self.statusbar.setObjectName("statusbar") 53 | MainWindow.setStatusBar(self.statusbar) 54 | 55 | self.retranslateUi(MainWindow) 56 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 57 | 58 | def retranslateUi(self, MainWindow): 59 | _translate = QtCore.QCoreApplication.translate 60 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 61 | self.lbl_sayi1.setText(_translate("MainWindow", "Sayi1 : ")) 62 | self.lbl_sayi2.setText(_translate("MainWindow", "Sayi 2 : ")) 63 | self.btn_topla.setText(_translate("MainWindow", "Toplam")) 64 | self.btn_cikarma.setText(_translate("MainWindow", "Cikarma")) 65 | self.btn_carpma.setText(_translate("MainWindow", "Carpma")) 66 | self.btn_bolme.setText(_translate("MainWindow", "Bolme")) 67 | self.lbl_sonuc.setText(_translate("MainWindow", "Sonuc : ")) 68 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/sekizincihafta/MainWindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 495 10 | 269 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 40 21 | 60 22 | 47 23 | 14 24 | 25 | 26 | 27 | Sayi1 : 28 | 29 | 30 | 31 | 32 | 33 | 40 34 | 90 35 | 47 36 | 14 37 | 38 | 39 | 40 | Sayi 2 : 41 | 42 | 43 | 44 | 45 | 46 | 110 47 | 60 48 | 181 49 | 20 50 | 51 | 52 | 53 | 54 | 55 | 56 | 110 57 | 90 58 | 181 59 | 20 60 | 61 | 62 | 63 | 64 | 65 | 66 | 110 67 | 130 68 | 75 69 | 23 70 | 71 | 72 | 73 | Toplam 74 | 75 | 76 | 77 | 78 | 79 | 190 80 | 130 81 | 75 82 | 23 83 | 84 | 85 | 86 | Cikarma 87 | 88 | 89 | 90 | 91 | 92 | 270 93 | 130 94 | 75 95 | 23 96 | 97 | 98 | 99 | Carpma 100 | 101 | 102 | 103 | 104 | 105 | 350 106 | 130 107 | 75 108 | 23 109 | 110 | 111 | 112 | Bolme 113 | 114 | 115 | 116 | 117 | 118 | 110 119 | 180 120 | 301 121 | 31 122 | 123 | 124 | 125 | Sonuc : 126 | 127 | 128 | 129 | 130 | 131 | 132 | 0 133 | 0 134 | 495 135 | 22 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/sekizincihafta/Ui_MainWindow.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'c:\Users\Nano\Downloads\sekizincihafta\MainWindow.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.15.11 6 | # 7 | # WARNING: Any manual changes made to this file will be lost when pyuic5 is 8 | # run again. Do not edit this file unless you know what you are doing. 9 | 10 | 11 | from PyQt5 import QtCore, QtGui, QtWidgets 12 | 13 | 14 | class Ui_MainWindow(object): 15 | def setupUi(self, MainWindow): 16 | MainWindow.setObjectName("MainWindow") 17 | MainWindow.resize(495, 269) 18 | self.centralwidget = QtWidgets.QWidget(MainWindow) 19 | self.centralwidget.setObjectName("centralwidget") 20 | self.lbl_sayi1 = QtWidgets.QLabel(self.centralwidget) 21 | self.lbl_sayi1.setGeometry(QtCore.QRect(40, 60, 47, 14)) 22 | self.lbl_sayi1.setObjectName("lbl_sayi1") 23 | self.lbl_sayi2 = QtWidgets.QLabel(self.centralwidget) 24 | self.lbl_sayi2.setGeometry(QtCore.QRect(40, 90, 47, 14)) 25 | self.lbl_sayi2.setObjectName("lbl_sayi2") 26 | self.txt_sayi1 = QtWidgets.QLineEdit(self.centralwidget) 27 | self.txt_sayi1.setGeometry(QtCore.QRect(110, 60, 181, 20)) 28 | self.txt_sayi1.setObjectName("txt_sayi1") 29 | self.txt_sayi2 = QtWidgets.QLineEdit(self.centralwidget) 30 | self.txt_sayi2.setGeometry(QtCore.QRect(110, 90, 181, 20)) 31 | self.txt_sayi2.setObjectName("txt_sayi2") 32 | self.btn_topla = QtWidgets.QPushButton(self.centralwidget) 33 | self.btn_topla.setGeometry(QtCore.QRect(110, 130, 75, 23)) 34 | self.btn_topla.setObjectName("btn_topla") 35 | self.btn_cikarma = QtWidgets.QPushButton(self.centralwidget) 36 | self.btn_cikarma.setGeometry(QtCore.QRect(190, 130, 75, 23)) 37 | self.btn_cikarma.setObjectName("btn_cikarma") 38 | self.btn_carpma = QtWidgets.QPushButton(self.centralwidget) 39 | self.btn_carpma.setGeometry(QtCore.QRect(270, 130, 75, 23)) 40 | self.btn_carpma.setObjectName("btn_carpma") 41 | self.btn_bolme = QtWidgets.QPushButton(self.centralwidget) 42 | self.btn_bolme.setGeometry(QtCore.QRect(350, 130, 75, 23)) 43 | self.btn_bolme.setObjectName("btn_bolme") 44 | self.lbl_sonuc = QtWidgets.QLabel(self.centralwidget) 45 | self.lbl_sonuc.setGeometry(QtCore.QRect(110, 180, 301, 31)) 46 | self.lbl_sonuc.setObjectName("lbl_sonuc") 47 | MainWindow.setCentralWidget(self.centralwidget) 48 | self.menubar = QtWidgets.QMenuBar(MainWindow) 49 | self.menubar.setGeometry(QtCore.QRect(0, 0, 495, 22)) 50 | self.menubar.setObjectName("menubar") 51 | MainWindow.setMenuBar(self.menubar) 52 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 53 | self.statusbar.setObjectName("statusbar") 54 | MainWindow.setStatusBar(self.statusbar) 55 | 56 | self.retranslateUi(MainWindow) 57 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 58 | 59 | def retranslateUi(self, MainWindow): 60 | _translate = QtCore.QCoreApplication.translate 61 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 62 | self.lbl_sayi1.setText(_translate("MainWindow", "Sayi1 : ")) 63 | self.lbl_sayi2.setText(_translate("MainWindow", "Sayi 2 : ")) 64 | self.btn_topla.setText(_translate("MainWindow", "Toplam")) 65 | self.btn_cikarma.setText(_translate("MainWindow", "Cikarma")) 66 | self.btn_carpma.setText(_translate("MainWindow", "Carpma")) 67 | self.btn_bolme.setText(_translate("MainWindow", "Bolme")) 68 | self.lbl_sonuc.setText(_translate("MainWindow", "Sonuc : ")) 69 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/sekizincihafta/calculator.py: -------------------------------------------------------------------------------- 1 | from PyQt5 import QtWidgets 2 | import sys 3 | from MainWindow import Ui_MainWindow 4 | 5 | class myApp(QtWidgets.QMainWindow): 6 | 7 | def __init__(self): 8 | super(myApp, self).__init__() 9 | self.ui = Ui_MainWindow() 10 | self.ui.setupUi(self) 11 | 12 | self.ui.btn_topla.clicked.connect(self.hesapla) 13 | self.ui.btn_cikarma.clicked.connect(self.hesapla) 14 | self.ui.btn_carpma.clicked.connect(self.hesapla) 15 | self.ui.btn_bolme.clicked.connect(self.hesapla) 16 | 17 | def hesapla(self): 18 | sender = self.sender().text() 19 | result = 0 20 | 21 | if sender == 'Toplam': 22 | result = int(self.ui.txt_sayi1.text()) + int(self.ui.txt_sayi2.text()) 23 | elif sender == 'Cikarma': 24 | result = int(self.ui.txt_sayi1.text()) - int(self.ui.txt_sayi2.text()) 25 | elif sender == 'Carpma': 26 | result = int(self.ui.txt_sayi1.text()) * int(self.ui.txt_sayi2.text()) 27 | elif sender == 'Bolme': 28 | result = int(self.ui.txt_sayi1.text()) / int(self.ui.txt_sayi2.text()) 29 | 30 | self.ui.lbl_sonuc.setText('sonuç: '+ str(result)) 31 | 32 | 33 | def app(): 34 | app = QtWidgets.QApplication(sys.argv) 35 | win = myApp() 36 | win.show() 37 | sys.exit(app.exec_()) 38 | 39 | app() 40 | 41 | 42 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ucuncuhafta/LineEdit.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QPushButton 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | self.lineEntry = QLineEdit(self) 10 | self.lineEntry.move(16,16) 11 | self.lineEntry.resize(200,100) 12 | 13 | self.qlabel = QLabel(self) 14 | self.qlabel.move(16,120) 15 | 16 | self.lineEntry.textChanged.connect(self.onChanged) 17 | 18 | self.setGeometry(50,50,320,200) 19 | self.setWindowTitle("QLineEdit Example") 20 | self.show() 21 | 22 | def onChanged(self, text): 23 | self.qlabel.setText(text) 24 | self.qlabel.adjustSize() 25 | 26 | if __name__ == '__main__': 27 | app = QApplication(sys.argv) 28 | ex = Example() 29 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ucuncuhafta/checkbox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QCheckBox 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | cb = QCheckBox('Movie', self) 10 | cb.move(20, 20) 11 | 12 | cb2 = QCheckBox('Music', self) 13 | cb2.move(20, 40) 14 | cb2.toggle() 15 | 16 | self.setGeometry(50,50,320,200) 17 | self.setWindowTitle("Checkbox Example") 18 | self.show() 19 | 20 | if __name__ == '__main__': 21 | app = QApplication(sys.argv) 22 | ex = Example() 23 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/ucuncuhafta/combobox.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QComboBox, QPushButton 3 | 4 | class Example(QMainWindow): 5 | 6 | def __init__(self): 7 | super().__init__() 8 | 9 | combo = QComboBox(self) 10 | combo.addItem("Apple") 11 | combo.addItem("Pear") 12 | combo.addItem("Lemon") 13 | 14 | combo.move(50, 50) 15 | 16 | self.qlabel = QLabel(self) 17 | self.qlabel.move(50,16) 18 | 19 | combo.activated[str].connect(self.onChanged) 20 | 21 | self.setGeometry(50,50,320,200) 22 | self.setWindowTitle("QLineEdit Example") 23 | self.show() 24 | 25 | def onChanged(self, text): 26 | self.qlabel.setText(text) 27 | self.qlabel.adjustSize() 28 | 29 | if __name__ == '__main__': 30 | app = QApplication(sys.argv) 31 | ex = Example() 32 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/Connection.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | print("Database created") 7 | except: 8 | print("failed to create database") 9 | finally: 10 | db.close() 11 | 12 | if __name__ == "__main__": 13 | main() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/CreateTable.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as sql 2 | 3 | def main(): 4 | try: 5 | db = sql.connect('TelefonDefteri.db') 6 | cur = db.cursor() 7 | tablequery = "CREATE TABLE Kullanicilar (id INT, isim TEXT, soyisim TEXT, sehir TEXT, telefon TEXT, email TEXT)" 8 | 9 | cur.execute(tablequery) 10 | print("Table Created Succesfully") 11 | 12 | except sql.Error as e: 13 | print("There is a table or an error has occurred") 14 | 15 | finally: 16 | db.close() 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteri.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteri.db -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/TelefonDefteriGUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'TelefonDefteriGUI.ui' 4 | # 5 | # Created by: PyQt5 UI code generator 5.13.2 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | 10 | from PyQt5 import QtCore, QtGui, QtWidgets 11 | 12 | 13 | class Ui_MainWindow(object): 14 | def setupUi(self, MainWindow): 15 | MainWindow.setObjectName("MainWindow") 16 | MainWindow.resize(910, 723) 17 | self.centralwidget = QtWidgets.QWidget(MainWindow) 18 | self.centralwidget.setObjectName("centralwidget") 19 | self.btnKaydet = QtWidgets.QPushButton(self.centralwidget) 20 | self.btnKaydet.setGeometry(QtCore.QRect(560, 20, 211, 41)) 21 | self.btnKaydet.setObjectName("btnKaydet") 22 | self.btnSil = QtWidgets.QPushButton(self.centralwidget) 23 | self.btnSil.setGeometry(QtCore.QRect(560, 70, 211, 41)) 24 | self.btnSil.setObjectName("btnSil") 25 | self.btnGuncelle = QtWidgets.QPushButton(self.centralwidget) 26 | self.btnGuncelle.setGeometry(QtCore.QRect(560, 120, 211, 41)) 27 | self.btnGuncelle.setObjectName("btnGuncelle") 28 | self.btnListele = QtWidgets.QPushButton(self.centralwidget) 29 | self.btnListele.setGeometry(QtCore.QRect(560, 170, 211, 41)) 30 | self.btnListele.setObjectName("btnListele") 31 | self.txtID = QtWidgets.QLineEdit(self.centralwidget) 32 | self.txtID.setGeometry(QtCore.QRect(220, 20, 311, 41)) 33 | self.txtID.setObjectName("txtID") 34 | self.txtIsim = QtWidgets.QLineEdit(self.centralwidget) 35 | self.txtIsim.setGeometry(QtCore.QRect(220, 70, 311, 41)) 36 | self.txtIsim.setObjectName("txtIsim") 37 | self.txtSoyisim = QtWidgets.QLineEdit(self.centralwidget) 38 | self.txtSoyisim.setGeometry(QtCore.QRect(220, 120, 311, 41)) 39 | self.txtSoyisim.setObjectName("txtSoyisim") 40 | self.txtSehir = QtWidgets.QLineEdit(self.centralwidget) 41 | self.txtSehir.setGeometry(QtCore.QRect(220, 170, 311, 41)) 42 | self.txtSehir.setObjectName("txtSehir") 43 | self.txtTelefon = QtWidgets.QLineEdit(self.centralwidget) 44 | self.txtTelefon.setGeometry(QtCore.QRect(220, 220, 311, 41)) 45 | self.txtTelefon.setObjectName("txtTelefon") 46 | self.txtEmail = QtWidgets.QLineEdit(self.centralwidget) 47 | self.txtEmail.setGeometry(QtCore.QRect(220, 270, 311, 41)) 48 | self.txtEmail.setObjectName("txtEmail") 49 | self.lblID = QtWidgets.QLabel(self.centralwidget) 50 | self.lblID.setGeometry(QtCore.QRect(10, 20, 201, 41)) 51 | self.lblID.setObjectName("lblID") 52 | self.lblISIM = QtWidgets.QLabel(self.centralwidget) 53 | self.lblISIM.setGeometry(QtCore.QRect(10, 70, 201, 41)) 54 | self.lblISIM.setObjectName("lblISIM") 55 | self.lblSoyisim = QtWidgets.QLabel(self.centralwidget) 56 | self.lblSoyisim.setGeometry(QtCore.QRect(10, 120, 201, 41)) 57 | self.lblSoyisim.setObjectName("lblSoyisim") 58 | self.lblSehir = QtWidgets.QLabel(self.centralwidget) 59 | self.lblSehir.setGeometry(QtCore.QRect(10, 170, 201, 41)) 60 | self.lblSehir.setObjectName("lblSehir") 61 | self.lblTelefon = QtWidgets.QLabel(self.centralwidget) 62 | self.lblTelefon.setGeometry(QtCore.QRect(10, 220, 201, 41)) 63 | self.lblTelefon.setObjectName("lblTelefon") 64 | self.lblEmail = QtWidgets.QLabel(self.centralwidget) 65 | self.lblEmail.setGeometry(QtCore.QRect(10, 270, 201, 41)) 66 | self.lblEmail.setObjectName("lblEmail") 67 | self.tblListele = QtWidgets.QTableWidget(self.centralwidget) 68 | self.tblListele.setGeometry(QtCore.QRect(10, 330, 891, 341)) 69 | self.tblListele.setObjectName("tblListele") 70 | self.tblListele.setColumnCount(0) 71 | self.tblListele.setRowCount(0) 72 | MainWindow.setCentralWidget(self.centralwidget) 73 | self.menubar = QtWidgets.QMenuBar(MainWindow) 74 | self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 22)) 75 | self.menubar.setObjectName("menubar") 76 | MainWindow.setMenuBar(self.menubar) 77 | self.statusbar = QtWidgets.QStatusBar(MainWindow) 78 | self.statusbar.setObjectName("statusbar") 79 | MainWindow.setStatusBar(self.statusbar) 80 | 81 | self.retranslateUi(MainWindow) 82 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 83 | 84 | def retranslateUi(self, MainWindow): 85 | _translate = QtCore.QCoreApplication.translate 86 | MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) 87 | self.btnKaydet.setText(_translate("MainWindow", "KAYDET")) 88 | self.btnSil.setText(_translate("MainWindow", "SIL")) 89 | self.btnGuncelle.setText(_translate("MainWindow", "GUNCELLE")) 90 | self.btnListele.setText(_translate("MainWindow", "LISTELE")) 91 | self.lblID.setText(_translate("MainWindow", "ID")) 92 | self.lblISIM.setText(_translate("MainWindow", "ISIM")) 93 | self.lblSoyisim.setText(_translate("MainWindow", "SOYISIM")) 94 | self.lblSehir.setText(_translate("MainWindow", "SEHIR")) 95 | self.lblTelefon.setText(_translate("MainWindow", "TELEFON")) 96 | self.lblEmail.setText(_translate("MainWindow", "EMAIL")) 97 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/Connection.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/Connection.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-313.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-313.pyc -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-37.pyc -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/__pycache__/TelefonDefteriGUI.cpython-38.pyc -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project-With-GUI/readme.md: -------------------------------------------------------------------------------- 1 | # PyQt5-SqLite-Crud-Project-With-GUI 2 | 3 | For the visual programming course, it was connected to the database with SQLite using the PyQT5 user interface and CRUD operations were performed. 4 | 5 | ![image](https://user-images.githubusercontent.com/5441882/94076479-df211400-fe05-11ea-82a8-8ef79ddcb9e9.png) 6 | 7 | ![image](https://user-images.githubusercontent.com/5441882/94076101-12af6e80-fe05-11ea-9cb7-05a1361d89ce.png) 8 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/Connection.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | def main(): 4 | try: 5 | db = lit.connect('./yedincihafta/PyQt5-SqLite-Crud-Project/myemployee.db') 6 | print("Database created") 7 | except: 8 | print("failed to create database") 9 | finally: 10 | db.close() 11 | 12 | if __name__ == "__main__": 13 | main() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/CreateTable.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | def main(): 4 | try: 5 | db = lit.connect('./yedincihafta/PyQt5-SqLite-Crud-Project/myemployee.db') 6 | cur = db.cursor() 7 | tablequery = "CREATE TABLE kullanicilar (id INT, name TEXT, email TEXT)" 8 | 9 | cur.execute(tablequery) 10 | print("Table Created Succesfully") 11 | 12 | except lit.Error as e: 13 | print("Unable To Create Table") 14 | 15 | finally: 16 | db.close() 17 | 18 | if __name__ == "__main__": 19 | main() -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/DeleteData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | 7 | newname = "updated name" 8 | user_id = 1 9 | 10 | cur = db.cursor() 11 | cur.execute('DELETE FROM users WHERE id = ? ', (user_id,) ) 12 | db.commit() 13 | print("Data Deleted Successfully") 14 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/SelectData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | cur = db.cursor() 7 | selectquery = "SELECT * FROM users" 8 | cur.execute(selectquery) 9 | 10 | rows = cur.fetchall() 11 | 12 | for data in rows: 13 | print(data) 14 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/UpdateData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | 3 | db = lit.connect('myemployee.db') 4 | 5 | with db: 6 | 7 | newname = "updated name" 8 | user_id = 4 9 | 10 | cur = db.cursor() 11 | cur.execute('UPDATE users SET name = ? WHERE id = ?', (newname, user_id)) 12 | db.commit() 13 | print("Data Updated Successfully") 14 | -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/insertData.py: -------------------------------------------------------------------------------- 1 | import sqlite3 as lit 2 | myuser = ( 3 | 4 | (1, 'Parwiz', 'par@gmail.com'), 5 | (2, 'John', 'john@gmail.com'), 6 | (3, 'Bob', 'bob@gmail.com'), 7 | (4, 'Tom', 'tom@gmail.com'), 8 | 9 | ) 10 | db = lit.connect('myemployee.db') 11 | 12 | with db: 13 | cur = db.cursor() 14 | cur.executemany('INSERT INTO users VALUES (?,?,?)', myuser) 15 | 16 | print("Data Inserted Successfully") -------------------------------------------------------------------------------- /Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/myemployee.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Codes/04-pyqt-haftalik-uygulamalar/yedincihafta/PyQt5-SqLite-Crud-Project/myemployee.db -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Dr. Nano / Sevdanur GENC 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Visual-Programming-PyQT-Lecture-Notes 2 | This repo contains lecture notes about Visual Programming with PyQT. 3 | 4 | Link to the playlist for all course content: https://www.youtube.com/playlist?list=PL2gbeBICuwU64wS9b6CtTRUL7Qc4G9HF5 5 | 6 | Note : Yes I know the sound quality is bad :) because at that time the video recording was kept in another distance education application. The important thing is the content :) 7 | 8 | ![image](https://github.com/user-attachments/assets/b6a25ad7-b4be-4f27-8de0-afcc7e7307a7) 9 | 10 | 11 | Download Link QT Designer : https://build-system.fman.io/qt-designer-download 12 | 13 | Install/Use PyQt5 in Visual Studio Code in Windows : https://www.youtube.com/watch?v=7LJpjIlEHIY 14 | 15 | Download and create an app using Qt Designer (for PyQt6, PyQt5, PySide6) : https://www.youtube.com/watch?v=4HgIAZyrqgU 16 | 17 | DB Browser for SQLite : https://sqlitebrowser.org and https://sqlitebrowser.org/dl/ 18 | 19 | SqLite Tutorial videos : https://www.youtube.com/playlist?list=PL2gbeBICuwU7SSDS7BC6-RZrltG_HADT3 20 | -------------------------------------------------------------------------------- /Slides/1. Bolum - Gorsel Programlama - Giris.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/1. Bolum - Gorsel Programlama - Giris.ppt -------------------------------------------------------------------------------- /Slides/10. Bolum - Gorsel Programlama - Datetime.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/10. Bolum - Gorsel Programlama - Datetime.ppt -------------------------------------------------------------------------------- /Slides/11. Bolum - Gorsel Programlama - Listbox.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/11. Bolum - Gorsel Programlama - Listbox.ppt -------------------------------------------------------------------------------- /Slides/12. Bolum - Gorsel Programlama - Tableview.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/12. Bolum - Gorsel Programlama - Tableview.ppt -------------------------------------------------------------------------------- /Slides/13. Bolum - Gorsel Programlama - SQLite.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/13. Bolum - Gorsel Programlama - SQLite.ppt -------------------------------------------------------------------------------- /Slides/14. Bolum - Gorsel Programlama - SQLite GUI Proje.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/14. Bolum - Gorsel Programlama - SQLite GUI Proje.ppt -------------------------------------------------------------------------------- /Slides/2. Bolum - Gorsel Programlama - ilk uygulama.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/2. Bolum - Gorsel Programlama - ilk uygulama.ppt -------------------------------------------------------------------------------- /Slides/3. Bolum - Gorsel Programlama - Tools.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/3. Bolum - Gorsel Programlama - Tools.ppt -------------------------------------------------------------------------------- /Slides/4. Bolum - Gorsel Programlama - Hesap Makinesi.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/4. Bolum - Gorsel Programlama - Hesap Makinesi.ppt -------------------------------------------------------------------------------- /Slides/5. Bolum - Gorsel Programlama - Layout.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/5. Bolum - Gorsel Programlama - Layout.ppt -------------------------------------------------------------------------------- /Slides/6. Bolum - Gorsel Programlama - Checkbox ve GroupBox.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/6. Bolum - Gorsel Programlama - Checkbox ve GroupBox.ppt -------------------------------------------------------------------------------- /Slides/7. Bolum - Gorsel Programlama - Radiobutton.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/7. Bolum - Gorsel Programlama - Radiobutton.ppt -------------------------------------------------------------------------------- /Slides/8. Bolum - Gorsel Programlama - Combobox.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/8. Bolum - Gorsel Programlama - Combobox.ppt -------------------------------------------------------------------------------- /Slides/9. Bolum - Gorsel Programlama - Msgbox.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SevdanurGENC/Visual-Programming-PyQT-Lecture-Notes/a4e17546a373a0d21df87dd66cd14774755d3a3a/Slides/9. Bolum - Gorsel Programlama - Msgbox.ppt --------------------------------------------------------------------------------