import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
 
class Window (QMainWindow) :
 
    def __init__ (self) :
        super().__init__ ()
 
        self.widget = QWidget (self)
 
        self.layout = QVBoxLayout (self.widget)
 
        self.setCentralWidget (self.widget)
 
        # self.setFont (QFont ("", 20))
 
        self.tree = QTreeWidget (self)
        self.tree.header().setVisible (False)
        self.layout.addWidget (self.tree)
 
        self.button = QPushButton (self)
        self.button.setText ("Add Items")
        self.button.clicked.connect (self.onClick)
 
        self.layout.addWidget (self.button)
 
    def onClick (self) :
 
        branch = QTreeWidgetItem (self.tree)
        branch.setText (0, "abc")
        branch.setForeground (0, QColor ("brown"))
        branch.setExpanded (True)
 
        colors = [ "red", "blue", "green", "yellow", "orange"]
        for name in colors :
           item = QTreeWidgetItem (branch)
           item.setText (0, name + " item")
           item.setForeground (0, QColor (name))
 
if __name__ == "__main__" :
    app = QApplication (sys.argv)
    win = Window ()
    win.show ()
    win.raise_ ()
    sys.exit (app.exec_ ())

import sys, os
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
 
class Window (QMainWindow) :
 
    def __init__ (self) :
        super().__init__ ()
 
        self.widget = QWidget (self)
 
        self.layout = QVBoxLayout (self.widget)
 
        self.setCentralWidget (self.widget)
 
        self.setFont (QFont ("", 20))
 
        self.tree = QTreeWidget (self)
        self.tree.header().setVisible (False)
        self.layout.addWidget (self.tree)
 
        self.checkbox = QCheckBox (self)
        self.checkbox.setText ("Check Box")
 
        self.layout.addWidget (self.checkbox)
 
        self.lineedit = QLineEdit (self)
        self.lineedit.setText ("Line Edit")
 
        self.layout.addWidget (self.lineedit)
 
        self.button = QPushButton (self)
        self.button.setText ("Knoflik")
        self.button.clicked.connect (self.onClick)
 
        self.layout.addWidget (self.button)
 
        self.output = QTextEdit (self)
        self.output.setText ("Text Edit")
 
        self.layout.addWidget (self.output)
 
    def onClick (self) :
        self.button.setText ("Click")
 
        self.output.append ( "checbox ..."  + str ( self.checkbox.isChecked () ))
        self.output.append ( "lineedit ..." + str ( self.lineedit.text ()      ))
        # os.system (self.lineedit.text ())
 
        branch = QTreeWidgetItem (self.tree)
        branch.setText (0, "abc")
        branch.setForeground (0, QColor ("brown"))
        branch.setExpanded (True)
 
        colors = [ "red", "blue", "green", "yellow", "orange"]
        for name in colors :
           item = QTreeWidgetItem (branch)
           item.setText (0, name + " item")
           item.setForeground (0, QColor (name))
 
def main () :
    app = QApplication (sys.argv)
    # i = "abc"
    # i = i + str (1)
    # win = None
    win = Window ()
    win.show ()
    win.raise_ ()
    # win.setWindowTitle(i)
    sys.exit (app.exec_ ())
 
if __name__ == "__main__" :
    main ()
 
 
"""
use_glob = True
try :
   from glob import *
   # import glob
except :
   use_glob = False
 
for name in glob ("c:\\temp\\*.zip") :
    print (name)
"""    
 
 
"""
a = [ 10, 20, 30 ]
 
# a = [ ] 
 
print ("pocet prvku", len (a))
 
for i in range (len (a)) :
    print ("prvek", i, "je", a[i])
 
def fact (n) :
    if n == 1 :
       return n * fact (n-1)
    else :
       return 1
 
def fact2 (n) :
    v = 1
    while n > 1 :
        v *= n
        n -= 1
    return v
 
print ("faktorial je", fact2 (5))
"""
 
"""
for v in a :
    # print (v)
    if v > 25 :
       print (v, " je prilis velke")
    elif v < 15 :
       print (v, " je prilis male")
    else :
       print (v, " je prijatelne")
 
    if v > 25 :
       print (v, " je prilis velke")
    else :
       if v < 15 :
          print (v, " je prilis male")
       else :
          print (v, " je prijatelne")
"""
 
uop/strom.txt · Last modified: 2022/02/03 18:22 by 88.103.111.44
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki