|
| 1 | +# get current virtual row -> win.rownum |
| 2 | +# QQ se riga con notebook cresce, fa casino; se più righe crescono, casino |
| 3 | +# have ":" refer to virtual row container |
| 4 | +# have a mean to create a frame and describe it |
| 5 | +# same for notebooks, have a mean to describe its pages |
| 6 | +# make radiobutton group |
| 7 | +# make combobox, listbox |
| 8 | +# implement a callback from parsedescription, such as the host can register |
| 9 | +# a function to create external widgets; for example, associate "cv" to |
| 10 | +# function that creates a Canvas; the library will insert that |
| 11 | + |
| 12 | +import tkinter as tk |
| 13 | + |
| 14 | +import sys, os |
| 15 | + |
| 16 | +fulpath = os.path.abspath(sys.argv[0]) |
| 17 | +if fulpath[0] == 'C': |
| 18 | + print("inc:", sys.argv[0]) |
| 19 | + sys.path.append("c:/dati/python apps/mylib") |
| 20 | + |
| 21 | +import tkabtgeom as UI |
| 22 | + |
| 23 | + |
| 24 | +for i in range(1, len(sys.argv)): |
| 25 | + arg = sys.argv[i] |
| 26 | + if arg.endswith("?"): |
| 27 | + UI.abtgeom.help(UI.abtgeom) |
| 28 | + exit() |
| 29 | + |
| 30 | +# UI.dbgopts = "=exFR" |
| 31 | +ui=UI.abtgeom(11, "Sans") |
| 32 | + |
| 33 | +win=ui.MainWin("wdMain", "This is Window Title",""" |
| 34 | + "Database:" |enInCsv-50= |
| 35 | + "Output:" |enOuCsv-50 |
| 36 | + "Filter 1" |btX1"X"-10 btR! btC btD enF1> ! |
| 37 | + "Filter 2 (value)" |btX2"X" sp-4 ck1"A check" |
| 38 | + "Filter 3" |btX3"X"-200 btPTH= >enF3-40 |
| 39 | + "A frame:" |erFR> |
| 40 | + sg1=! ! |
| 41 | + nb1=! ! |
| 42 | + """) |
| 43 | + |
| 44 | + # in general: opts+type&name+"optional_text"+width+opts |
| 45 | + # so like "enName", btDo"Click here", |enName-20 |
| 46 | + # leading | like "|bt1" aligns left of several widget |
| 47 | + # leading > like ">bt1" moves widget to the far right (all the following too) |
| 48 | + # trailing > like "enF1>" grows and align to left of following element |
| 49 | + # trailing = like "btPTH=" grows width proportionally to the growth of window |
| 50 | + # trailing ! like "btX1!" means expand vertically the widget |
| 51 | + # trailing ! (or !) LAST IN LINE (with no names) means expand row vertically |
| 52 | + |
| 53 | +fr = win.child("erFR") |
| 54 | +fr.pack(tk.Checkbutton(fr.widget, text="A checkbox")) |
| 55 | +fr.yg = f"TT{fr.rowcont.name}+M,BB{fr.rowcont.name}" |
| 56 | + |
| 57 | + |
| 58 | +# reconfigure sg |
| 59 | +win.StringgridConfigure("sg1", ['Item ID|80', 'Description|280','Designators|280','Qty|60','Oth1', 'Oth2']) |
| 60 | +# win.child("sg1").yg += ",BBvr6" |
| 61 | +# win.child("sg1").yg += ",hh." |
| 62 | +for i in range(10): |
| 63 | + win.child("sg1").widget.insert('', tk.END, values=("Val"+str(i), "2nd Column", "List of designators (col3)")) |
| 64 | + |
| 65 | +# configure notebook |
| 66 | +nbpags = win.NotebookConfigure("nb1", ["First tab", "Another tab", "Third tab"]) |
| 67 | +nbpags[0].configure(relief="sunken") |
| 68 | +nbpags[1].configure(relief="ridge") |
| 69 | + |
| 70 | +# win.children["enInCsv"].xg += ",RW.-M" # aligns right to right.margin (or -number) |
| 71 | +win.children["enOuCsv"].xg += ",RRenInCsv" # aligns right to right of enInCsv |
| 72 | + |
| 73 | +# win.children["btPTH"].xg += ",WW./2" # width is half of window width |
| 74 | +#win.children["btPTH"].xg += ",ww." # adds to base width the growth of window (same as trailing >) |
| 75 | + |
| 76 | +#win.children["btPTH"].xg += ",RLenF3-M" # fills remaining space in row (same as trailing >) |
| 77 | + |
| 78 | +#win.children["enF1"].xg += ",ww./2" # adds to base width half the growth of window |
| 79 | +#win.children["enF3"].xg = "rW.-M" # align right in the window (same as leading >) |
| 80 | + |
| 81 | +#lb = win.Label('l1r1', 'A label') |
| 82 | +##lb2 = win.Label('lb2', "Another label", "", "MMbt1") |
| 83 | +##win.BreakLine() |
| 84 | +##lb3 = win.Label("lb3", "Label under") |
| 85 | +##lb4 = win.Label("lb4", "More rightside") |
| 86 | +##lb4.xg = "LRlb3+40,W180" |
| 87 | + |
| 88 | +win.BreakLine() |
| 89 | +win.Label("", "Database:") |
| 90 | +win.Entry("enOne", "", 50, "courier") |
| 91 | + |
| 92 | +# win.children["enOne"].xg += ",RW.-M" |
| 93 | +win.child("enOne").xg += ",RW.-M" |
| 94 | + |
| 95 | +############################ NOTEBOOK |
| 96 | +# win.BreakLine() |
| 97 | +# nb = win.Notebook("nb1", ["Page 1", "Page 2", "Page 3"]) |
| 98 | +# win.child("nb1").xg = "RR.-M" |
| 99 | + |
| 100 | +############################ LAST ROW (BUTTONS) |
| 101 | +win.BreakLine() |
| 102 | +bt = win.Button('btInfo', 'Info', lambda: [win.listwidgets(), print(f"frame={myex.getgeo()}")]) |
| 103 | +win.Button("btUpd", "Update", win.update) |
| 104 | + |
| 105 | +myex = win.Exframe("exFR2", relief="sunken") |
| 106 | + |
| 107 | +# print(f"exFR2.vg: {myex.yg}") |
| 108 | + |
| 109 | +myexw = win.child("exFR2") |
| 110 | +myexww = myexw.widget |
| 111 | +# win.child("exFR2").xg +=",RW.-M" |
| 112 | +win.child("exFR2").xg +=",ww.+M" |
| 113 | + |
| 114 | +#lab = tk.Label(myexww, text="Hello") |
| 115 | +#lab.pack() # already ok |
| 116 | +#lab.update() # to update its frame |
| 117 | +lab = myex.pack(tk.Label(myexww, text="Hello")) |
| 118 | + |
| 119 | +achk = myex.pack(tk.Checkbutton(myexww, text="Confirm")) |
| 120 | + |
| 121 | +ck2 = win.addwidget("ck2", tk.Checkbutton(win.widget, text="Confirmation 2")) |
| 122 | + |
| 123 | +#print(f"frame={myexww.winfo_reqwidth()}, lab={lab.winfo_reqwidth()}") |
| 124 | + |
| 125 | +ui.mainloop() |
| 126 | + |
0 commit comments