I want to make some application for SEO purposes to manage articles and requests.
1. Programm will have GUI
2. Programm will store all changes in database. Request will be one table.
2.1 Probably it is better to use object oriented databases like MongoDB.
1. To create GUI could be used PySimpleGUI, wxPython, PyQt, Tkinter, Remi, PySide
2. To install PySimpleGUI $ python -m pip install pysimplegui
1. Window elements:
import PySimpleGUI as s
s.Window(title="Hi it is title here", layout = [[]], margins=(100,50)).read(timeout=100)
2. At the end always use window.close() to clear memory
3. To add row window.extend_layout() or window.AddRow()
4. Table. How to make it scrollable horizontally. // Add vertical_scroll_only=False Helped
5. How to Scroll over window. Try to put everething inside the column element. // Nothing
5.1. Add parameter to column scrollable=True // helped
5.2. Better use vertical_scroll_only=True // Scroll disappeared
5.3. Return scrollable=True along with vertical_scroll_only=True // Now my table is not scrollable horizontally.
6. I'll try other GUI, pyGUISimple is not completly suitable for me.
1. To install $ pip install pyqt6 // I've got an error during dependencies installation
1.1. $ pip install pyqt5 // same error. AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
1.1.1. I did $ pip install pyqt5==5.15.0 // worked
1.1.2. How to get all available versions in pip // $ pip3 install pyqt5==
1.1.3. Get an error while installation: Command "python setup.py egg_info" failed with error code 1 // Update setuptools doesn't helped
1.1.3.1 Try to update pip // helped
1.1.4 To install pyqt5 I need python version 3.6 // Try to $ sudo apt-get install python3-pyqt5
2. Simplest programm:
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QPushButton, QVBoxLayout
app = QApplication([])
wind = QWidget()
L = QVBoxLayout()
L.addWidget(QPushButton('Top'))
L.addWidget(QPushButton('Bottom'))
wind.setLayout(L)
wind.show()
app.exec()
3. How to connect an event to function handler // element_name.clicked.connect(function_handler)
4. To construct graphical interface use Qt Designer // $ pip install pyqt5 pyqt5-tools
4.1 Start it from /your_virtual_env_directory/lib/python/site-packages/qt5_applications/Qt/bin/
5. How to clear layout.
for i in reversed(range(layout.count())):
widget = layout.itemAt(i).widget()
layout.removeWidget(widget) # remove from the layout list
widget.setParent(None) # remove from the GUI
5.1. Use deleteLater() // It doesn't delete from screen
def clearLayout(layout):
while layout.count():
child = layout.takeAt(0)
if child.widget():
child.widget().deleteLater()
5.2. Add child.widget().setParent(None) // Doesn't work
5.3. Doesn't working
def clearLayout(layout):
if layout is not None:
while layout.count():
child = layout.takeAt(0)
if child.widget() is not None:
child.widget().deleteLater()
elif child.layout() is not None:
clearLayout(child.layout())
5.4. One more time // I have problems with setParent(None)
def clearLayout(self):
if self.layout is not None:
old_layout = self.layout
for i in reversed(range(old_layout.count())):
old_layout.itemAt(i).widget().setParent(None)
import sip
sip.delete(old_layout)
5.5 Works.
for i in reversed(range(layout.count())):
if layout.itemAt(i).widget():
layout.itemAt(i).widget().setParent(None)
else:
layout.removeItem(layout.itemAt(i))
1. Table. How to increment rows // table.setRowCount(rows+1)
2. Table. To set cell value. // table.setItem(row, column, QTableWidgetItem(value))
3. To add values into table use table.setModel(model)
4. To create standalone binary executables use fbs
5. Table. How to fit cell size to text. // table.resizeRowsToContent
6. Table. Align text in a table. // tableWidgetEl.setTextAlignment(Qt.AlignHCenter)
7. Layout. How to evenly align elements. // add layout.addStretch() between items.
8. Set default item for list widget. // Uset setCurrentItem(item_name)
9. Table. Set row color.
for i in range(how_many_columns_we_have):
my_table.item(0,i).setBackground(QtGui.QColor('light green'))
10. Table. Set bold font.
font = QtGui.QFont()
font.setBold(True)
my_table.item(i,j).setFont(font)
11. Tabs. Get tab's name. // tabs.tabText(tabs.currentIndex())
12. List. Set default value. // list_name.setCurrentRow(some_index)
13. Table. How to clear table. // Try table_name.setRowCount(0)