• R/O
  • SSH

tkpane: Commit

Default repository for tkpane.py.


Commit MetaInfo

Revisãof8511531f5f705604e790bbda519402ea3cfff14 (tree)
Hora2018-03-11 04:04:03
AutorDreas Nielsen <dreas.nielsen@gmai...>
CommiterDreas Nielsen

Mensagem de Log

Made use of Tkinter or ttk widgets in tkpane.lib configurable.

Mudança Sumário

Diff

diff -r d332105b830e -r f8511531f5f7 CHANGELOG.rst
--- a/CHANGELOG.rst Sat Mar 10 09:33:32 2018 -0800
+++ b/CHANGELOG.rst Sat Mar 10 11:04:03 2018 -0800
@@ -4,6 +4,7 @@
44 ========== ======= =================================================================================
55 Date Version Revision
66 ========== ======= =================================================================================
7+2018-03-10 0.26.0 Added 'set_entry_validator()' method to EntryPane in lib.py. Changed invalid colors to be configurable at module level. Changed use of ttk or tk widgets to be configurable at the module level.
78 2018-03-01 0.22.0 Added 'requires_datavalue() and 'clear_on_disable()' methods. Improved support for 'on_save_change' callback list. Added 'set_filename_validator()' method to InputFilePane.
89 2018-02-27 0.19.0 Added 'on_save_change' callback list. Added missing 'entry_widgets()' method to UserPasswordPane.
910 2018-02-27 0.18.0 Backwards-incompatible change since 0.14.0: changed object returned by 'build_ui()' to a dict. Added 'tab_frames()' method to NotebookPane. Set the CheckboxPane's value to False even when False is considered an invalid state.
diff -r d332105b830e -r f8511531f5f7 doc/source/index.rst
--- a/doc/source/index.rst Sat Mar 10 09:33:32 2018 -0800
+++ b/doc/source/index.rst Sat Mar 10 11:04:03 2018 -0800
@@ -659,6 +659,17 @@
659659
660660
661661
662+Changing Widget Types in ``tkpane.lib``
663+==============================================================
664+
665+The pane classes in ``tkpane.lib`` use ttk widgets by default (if
666+a ttk version of a widget exists). Tkinter widgets can be used
667+instead, as determined by the ``tkpane.use_ttk`` configuration
668+variable. If this is set to False, subsequent panes instantiated
669+from ``tkpane.lib`` will use Tkinter widgets instead of ttk
670+widgets, where possible.
671+
672+
662673 Package Contents
663674 ==============================================================
664675
@@ -877,7 +888,12 @@
877888 self.datakeylist = [self.datakeyname]
878889 self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
879890 self.entry_var = tk.StringVar()
880- self.entrywidget = ttk.Entry(self, textvariable=self.entry_var, exportselection=False)
891+ if tkpane.use_ttk:
892+ self.entrywidget = ttk.Entry(self, textvariable=self.entry_var, exportselection=False)
893+ self.widget_type = "ttk"
894+ else:
895+ self.entrywidget = tk.Entry(self, textvariable=self.entry_var, exportselection=False)
896+ self.widget_type = "tk"
881897 self.prompt.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
882898 self.entrywidget.grid(row=0, column=1, padx=3, pady=3, sticky=tk.EW)
883899 self.rowconfigure(0, weight=1)
diff -r d332105b830e -r f8511531f5f7 setup.py
--- a/setup.py Sat Mar 10 09:33:32 2018 -0800
+++ b/setup.py Sat Mar 10 11:04:03 2018 -0800
@@ -2,7 +2,7 @@
22
33 setup(name='tkpane',
44 packages=['tkpane'],
5- version='0.25.0',
5+ version='0.26.0',
66 description="Encapsulates Tkinter UI elements in 'panes' that can be combined into an overall UI, integrating them by specifying callback functions and data keys.",
77 author='Dreas Nielsen',
88 author_email='dreas.nielsen@gmail.com',
diff -r d332105b830e -r f8511531f5f7 test/test_invalid.py
--- a/test/test_invalid.py Sat Mar 10 09:33:32 2018 -0800
+++ b/test/test_invalid.py Sat Mar 10 11:04:03 2018 -0800
@@ -72,6 +72,8 @@
7272 button1 = panes["button1"]
7373 button2 = panes["button2"]
7474
75+text.append("Use_ttk = %s" % tkpane.use_ttk)
76+
7577 entry2.keys_to_enable = ["No such key will ever be generated."]
7678 tkpane.enable_or_disable_all([entry2])
7779
diff -r d332105b830e -r f8511531f5f7 tkpane/lib.py
--- a/tkpane/lib.py Sat Mar 10 09:33:32 2018 -0800
+++ b/tkpane/lib.py Sat Mar 10 11:04:03 2018 -0800
@@ -24,7 +24,7 @@
2424 for creation of other custom pane classes.
2525 """
2626
27-__version__ = "0.11.0"
27+__version__ = "0.12.0"
2828
2929
3030 try:
@@ -50,6 +50,7 @@
5050
5151
5252
53+
5354 #===============================================================================
5455 # Pane styles
5556 # A style is a set of options for pane (frame) configuration and gridding.
@@ -194,7 +195,12 @@
194195 tkpane.TkPane.__init__(self, parent, pane_name, frame_config_opts(), frame_grid_opts())
195196 self.button_text = button_text
196197 self.action = button_action if button_action is not None else do_nothing
197- self.btn = ttk.Button(self, text=self.button_text, command=self.do_button_action)
198+ if tkpane.use_ttk:
199+ self.btn = ttk.Button(self, text=self.button_text, command=self.do_button_action)
200+ self.widget_type = "ttk"
201+ else:
202+ self.btn = tk.Button(self, text=self.button_text, command=self.do_button_action)
203+ self.widget_type = "tk"
198204 if width is not None:
199205 self.btn.configure(width=width)
200206 self.btn.grid(row=0, column=1, padx=3, sticky=tk.E)
@@ -271,6 +277,7 @@
271277 def __init__(self, parent, width=None, height=None, config_opts=None):
272278 self.pane_name = "Canvas"
273279 tkpane.TkPane.__init__(self, parent, self.pane_name, frame_config_opts(), frame_grid_opts())
280+ self.widget_type = "tk"
274281 self.canvaswidget = tk.Canvas(self)
275282 if width is not None:
276283 self.canvaswidget.configure(width=width)
@@ -361,7 +368,12 @@
361368 self.checkvar = tk.BooleanVar()
362369 self.checkvar.set(False)
363370 self.datadict[self.datakeyname] = self.checkvar.get()
364- self.checkbox = ttk.Checkbutton(self, text=prompt, variable=self.checkvar, onvalue=True, offvalue=False)
371+ if tkpane.use_ttk:
372+ self.checkbox = ttk.Checkbutton(self, text=prompt, variable=self.checkvar, onvalue=True, offvalue=False)
373+ self.widget_type = "ttk"
374+ else:
375+ self.checkbox = tk.Checkbutton(self, text=prompt, variable=self.checkvar, onvalue=True, offvalue=False)
376+ self.widget_type = "tk"
365377 if config_opts is not None:
366378 self.checkbox.configure(**config_opts)
367379 self.checkbox.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
@@ -477,7 +489,12 @@
477489 self.datakeylist = [self.datakeyname]
478490 self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
479491 self.entry_var = tk.StringVar()
480- self.entrywidget = ttk.Combobox(self, textvariable=self.entry_var, values=items, width=max(map(len, map(str, items)))+1, exportselection=False)
492+ if tkpane.use_ttk:
493+ self.entrywidget = ttk.Combobox(self, textvariable=self.entry_var, values=items, width=max(map(len, map(str, items)))+1, exportselection=False)
494+ self.widget_type = "ttk"
495+ else:
496+ self.entrywidget = tk.Combobox(self, textvariable=self.entry_var, values=items, width=max(map(len, map(str, items)))+1, exportselection=False)
497+ self.widget_type = "tk"
481498 self.prompt.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
482499 self.entrywidget.grid(row=0, column=1, padx=3, pady=3, sticky=tk.W)
483500 self.rowconfigure(0, weight=1)
@@ -622,7 +639,12 @@
622639 self.entry_validator = None
623640 self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
624641 self.entry_var = tk.StringVar()
625- self.entrywidget = ttk.Entry(self, textvariable=self.entry_var, exportselection=False)
642+ if tkpane.use_ttk:
643+ self.entrywidget = ttk.Entry(self, textvariable=self.entry_var, exportselection=False)
644+ self.widget_type = "ttk"
645+ else:
646+ self.entrywidget = tk.Entry(self, textvariable=self.entry_var, exportselection=False)
647+ self.widget_type = "tk"
626648 self.prompt.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
627649 self.entrywidget.grid(row=0, column=1, padx=3, pady=3, sticky=tk.EW)
628650 self.rowconfigure(0, weight=1)
@@ -750,13 +772,20 @@
750772 self.datakeyname = "input_filename"
751773 self.datakeylist = [self.datakeyname]
752774 self.filename_validator = None
753- # Create, configure, and place widgets.
754- self.dir_label = ttk.Label(self, text='Input file:', width=12, anchor=tk.E)
755775 self.file_var = tk.StringVar()
776+ # Create, configure, and place widgets.
777+ if tkpane.use_ttk:
778+ self.dir_label = ttk.Label(self, text='Input file:', width=12, anchor=tk.E)
779+ self.file_display = ttk.Entry(self, textvariable=self.file_var)
780+ self.browse_button = ttk.Button(self, text='Browse', width=8, command=self.set_inputfile)
781+ self.widget_type = "ttk"
782+ else:
783+ self.dir_label = tk.Label(self, text='Input file:', width=12, anchor=tk.E)
784+ self.file_display = tk.Entry(self, textvariable=self.file_var)
785+ self.browse_button = tk.Button(self, text='Browse', width=8, command=self.set_inputfile)
786+ self.widget_type = "tk"
756787 self.file_var.trace("w", self.check_entrychange)
757- self.file_display = ttk.Entry(self, textvariable=self.file_var)
758788 self.valid_color = self.file_display.cget("background")
759- self.browse_button = ttk.Button(self, text='Browse', width=8, command=self.set_inputfile)
760789 self.dir_label.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
761790 self.file_display.grid(row=0, column=1, padx=3, pady=3, sticky=tk.EW)
762791 self.browse_button.grid(row=1, column=1, padx=3, pady=1, sticky=tk.W)
@@ -906,12 +935,18 @@
906935 self.datakeylist = [self.datakeyname]
907936 self.filename_validator = None
908937 # Create, configure, and place widgets.
909- self.dir_label = ttk.Label(self, text='Input file:', width=12, anchor=tk.W)
910938 self.file_var = tk.StringVar()
911- self.file_var.trace("w", self.check_entrychange)
912- self.file_display = ttk.Entry(self, textvariable=self.file_var)
939+ if tkpane.use_ttk:
940+ self.dir_label = ttk.Label(self, text='Input file:', width=12, anchor=tk.W)
941+ self.file_display = ttk.Entry(self, textvariable=self.file_var)
942+ self.browse_button = ttk.Button(self, text='Browse', width=8, command=self.set_inputfile)
943+ self.widget_type = "ttk"
944+ else:
945+ self.dir_label = tk.Label(self, text='Input file:', width=12, anchor=tk.W)
946+ self.file_display = tk.Entry(self, textvariable=self.file_var)
947+ self.browse_button = tk.Button(self, text='Browse', width=8, command=self.set_inputfile)
948+ self.widget_type = "tk"
913949 self.valid_color = self.file_display.cget("background")
914- self.browse_button = ttk.Button(self, text='Browse', width=8, command=self.set_inputfile)
915950 self.dir_label.grid(row=0, column=0, padx=3, pady=(3,2), sticky=tk.W)
916951 self.file_display.grid(row=1, column=0, padx=(3,2), pady=(2,3), sticky=tk.EW)
917952 self.browse_button.grid(row=1, column=1, padx=(2,3), pady=3, sticky=tk.W)
@@ -921,6 +956,7 @@
921956 parent.rowconfigure(0, weight=0)
922957 parent.rowconfigure(0, weight=1)
923958 parent.columnconfigure(0, weight=1)
959+ self.file_var.trace("w", self.check_entrychange)
924960
925961 #---------------------------------------------------------------------------
926962 # Overrides of class methods.
@@ -1059,9 +1095,13 @@
10591095 tkpane.TkPane.__init__(self, parent, pane_name, frame_config_opts(), frame_grid_opts())
10601096 self.datakeyname = "listbox" if key_name is None else key_name
10611097 self.datakeylist = [self.datakeyname]
1062- self.scroller = ttk.Scrollbar(self, orient=tk.VERTICAL)
1098+ if tkpane.use_ttk:
1099+ self.scroller = ttk.Scrollbar(self, orient=tk.VERTICAL)
1100+ else:
1101+ self.scroller = tk.Scrollbar(self, orient=tk.VERTICAL)
10631102 ht = 10 if rows is None else rows
10641103 selmode = "extended" if mode is None else mode
1104+ self.widget_type = "tk"
10651105 self.listbox = tk.Listbox(self, selectmode=selmode, exportselection=False, yscrollcommand=self.scroller.set, height=ht)
10661106 if width is not None:
10671107 self.listbox.configure(width=width)
@@ -1178,7 +1218,12 @@
11781218 self.msg_label = None
11791219 def wrap_mp_msg(event):
11801220 self.msg_label.configure(wraplength=event.width - 5)
1181- self.msg_label = ttk.Label(self, text=message)
1221+ if tkpane.use_ttk:
1222+ self.msg_label = ttk.Label(self, text=message)
1223+ self.widget_type = "ttk"
1224+ else:
1225+ self.msg_label = tk.Label(self, text=message)
1226+ self.widget_type = "tk"
11821227 self.msg_label.bind("<Configure>", wrap_mp_msg)
11831228 self.msg_label.grid(column=0, row=0, sticky=tk.EW, padx=6, pady=6)
11841229 parent.rowconfigure(0, weight=0)
@@ -1221,6 +1266,7 @@
12211266 tkpane.TkPane.__init__(self, parent, pane_name, frame_config_opts(), frame_grid_opts())
12221267 self.tabids = {}
12231268 self.tabframes = {}
1269+ self.widget_type = "ttk"
12241270 self.nb_widget = ttk.Notebook(self)
12251271 id_no = 0
12261272 for tab in tab_specs:
@@ -1289,10 +1335,16 @@
12891335 pass
12901336 tkpane.TkPane.__init__(self, parent, "OK/Cancel", frame_config_opts(), frame_grid_opts())
12911337 self.ok_action = ok_action if ok_action is not None else do_nothing
1292- self.cancel_action = cancel_action if cancel_action is not None else do_nothing
1293- self.cancel_btn = ttk.Button(self, text="Cancel", command=self.cancel_action)
1338+ self.cancel_action = cancel_action if cancel_action is not None else do_nothing
1339+ if tkpane.use_ttk:
1340+ self.cancel_btn = ttk.Button(self, text="Cancel", command=self.cancel_action)
1341+ self.ok_btn = ttk.Button(self, text="OK", command=self.ok_action)
1342+ self.widget_type = "ttk"
1343+ else:
1344+ self.cancel_btn = tk.Button(self, text="Cancel", command=self.cancel_action)
1345+ self.ok_btn = tk.Button(self, text="OK", command=self.ok_action)
1346+ self.widget_type = "tk"
12941347 self.cancel_btn.grid(row=0, column=1, padx=3, sticky=tk.E)
1295- self.ok_btn = ttk.Button(self, text="OK", command=self.ok_action)
12961348 self.ok_btn.grid(row=0, column=0, padx=3, sticky=tk.E)
12971349 self.columnconfigure(0, weight=1)
12981350 self.columnconfigure(1, weight=0)
@@ -1361,12 +1413,18 @@
13611413 self.datakey = "output_dir"
13621414 self.datakeylist = [self.datakey]
13631415 # Create, configure, and place widgets.
1364- self.dir_label = tk.Label(self, text='Output directory:', width=18, anchor=tk.E)
13651416 self.dir_var = tk.StringVar()
1366- self.dir_var.trace("w", self.check_entrychange)
1367- self.dir_display = ttk.Entry(self, textvariable=self.dir_var)
1417+ if tkpane.use_ttk:
1418+ self.dir_label = ttk.Label(self, text='Output directory:', width=18, anchor=tk.E)
1419+ self.dir_display = ttk.Entry(self, textvariable=self.dir_var)
1420+ self.dir_button = ttk.Button(self, text='Browse', width=8, command=self.set_outputdir)
1421+ self.widget_type = "ttk"
1422+ else:
1423+ self.dir_label = tk.Label(self, text='Output directory:', width=18, anchor=tk.E)
1424+ self.dir_display = tk.Entry(self, textvariable=self.dir_var)
1425+ self.dir_button = tk.Button(self, text='Browse', width=8, command=self.set_outputdir)
1426+ self.widget_type = "tk"
13681427 self.valid_color = self.dir_display.cget("background")
1369- self.dir_button = ttk.Button(self, text='Browse', width=8, command=self.set_outputdir)
13701428 self.dir_label.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
13711429 self.dir_display.grid(row=0, column=1, padx=3, pady=3, sticky=tk.EW)
13721430 self.dir_button.grid(row=1, column=1, padx=3, pady=1, sticky=tk.W)
@@ -1375,6 +1433,7 @@
13751433 self.rowconfigure(1, weight=1)
13761434 parent.rowconfigure(0, weight=0)
13771435 parent.columnconfigure(0, weight=1)
1436+ self.dir_var.trace("w", self.check_entrychange)
13781437
13791438 #---------------------------------------------------------------------------
13801439 # Overrides of class methods.
@@ -1495,12 +1554,18 @@
14951554 self.datakey = "output_filename"
14961555 self.datakeylist = [self.datakey]
14971556 # Create, configure, and place widgets.
1498- self.dir_label = ttk.Label(self, text='Output file:', width=12, anchor=tk.E)
14991557 self.file_var = tk.StringVar()
1500- self.file_var.trace("w", self.check_entrychange)
1501- self.file_display = ttk.Entry(self, textvariable=self.file_var)
1558+ if tkpane.use_ttk:
1559+ self.dir_label = ttk.Label(self, text='Output file:', width=12, anchor=tk.E)
1560+ self.file_display = ttk.Entry(self, textvariable=self.file_var)
1561+ self.browse_button = ttk.Button(self, text='Browse', width=8, command=self.set_outputfile)
1562+ self.widget_type = "ttk"
1563+ else:
1564+ self.dir_label = tk.Label(self, text='Output file:', width=12, anchor=tk.E)
1565+ self.file_display = tk.Entry(self, textvariable=self.file_var)
1566+ self.browse_button = tk.Button(self, text='Browse', width=8, command=self.set_outputfile)
1567+ self.widget_type = "tk"
15021568 self.valid_color = self.file_display.cget("background")
1503- self.browse_button = tk.Button(self, text='Browse', width=8, command=self.set_outputfile)
15041569 self.dir_label.grid(row=0, column=0, padx=3, pady=3, sticky=tk.EW)
15051570 self.file_display.grid(row=0, column=1, padx=3, pady=3, sticky=tk.EW)
15061571 self.browse_button.grid(row=1, column=1, padx=3, pady=1, sticky=tk.W)
@@ -1509,6 +1574,7 @@
15091574 self.rowconfigure(1, weight=1)
15101575 parent.rowconfigure(0, weight=0)
15111576 parent.columnconfigure(0, weight=1)
1577+ self.file_var.trace("w", self.check_entrychange)
15121578
15131579 #---------------------------------------------------------------------------
15141580 # Overrides of class methods.
@@ -1645,7 +1711,12 @@
16451711 self.datakeylist = [self.datakeyname]
16461712 self.entry_var = tk.DoubleVar()
16471713 self.entry_var.set(init_value)
1648- self.entrywidget = ttk.Scale(self, variable=self.entry_var, length=length, orient=orientation, from_=min_value, to=max_value, value=init_value)
1714+ if tkpane.use_ttk:
1715+ self.entrywidget = ttk.Scale(self, variable=self.entry_var, length=length, orient=orientation, from_=min_value, to=max_value, value=init_value)
1716+ self.widget_type = "ttk"
1717+ else:
1718+ self.entrywidget = tk.Scale(self, variable=self.entry_var, length=length, orient=orientation, from_=min_value, to=max_value, value=init_value)
1719+ self.widget_type = "tk"
16491720 if config_opts is not None:
16501721 self.entrywidget.configure(**config_opts)
16511722 sticky = tk.EW if orientation == tk.HORIZONTAL else tk.NS
@@ -1742,11 +1813,22 @@
17421813 self.datakeylist = [self.datakeyname]
17431814 self.entry_var = tk.DoubleVar()
17441815 self.entry_var.set(init_value)
1745- self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
1746- self.entrywidget = ttk.Scale(self, variable=self.entry_var, orient=tk.HORIZONTAL, from_=min_value, to=max_value, value=init_value)
1816+ if tkpane.use_ttk:
1817+ self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
1818+ self.entrywidget = ttk.Scale(self, variable=self.entry_var, orient=tk.HORIZONTAL, from_=min_value, to=max_value, value=init_value)
1819+ try:
1820+ # For the future.
1821+ self.spinwidget = ttk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1822+ except:
1823+ self.spinwidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1824+ self.widget_type = "ttk"
1825+ else:
1826+ self.prompt = tk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
1827+ self.entrywidget = tk.Scale(self, variable=self.entry_var, orient=tk.HORIZONTAL, from_=min_value, to=max_value, value=init_value)
1828+ self.spinwidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1829+ self.widget_type = "tk"
17471830 if length is not None:
17481831 self.entrywidget.configure(length=length)
1749- self.spinwidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
17501832 if scale_config_opts is not None:
17511833 self.entrywidget.configure(**scale_config_opts)
17521834 if spin_config_opts is not None:
@@ -1854,9 +1936,19 @@
18541936 self.min_value = min_value
18551937 self.datakeyname = "spinbox" if key_name is None else key_name
18561938 self.datakeylist = [self.datakeyname]
1857- self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
18581939 self.entry_var = tk.StringVar()
1859- self.entrywidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1940+ if tkpane.use_ttk:
1941+ self.prompt = ttk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
1942+ try:
1943+ # For the future.
1944+ self.entrywidget = ttk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1945+ except:
1946+ self.entrywidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1947+ self.widget_type = "ttk"
1948+ else:
1949+ self.prompt = tk.Label(self, text=prompt, width=max(12, len(prompt)), anchor=tk.E)
1950+ self.entrywidget = tk.Spinbox(self, from_=min_value, to=max_value, textvariable=self.entry_var, width=len(str(max_value))+1, exportselection=False)
1951+ self.widget_type = "tk"
18601952 self.entry_var.set(min_value)
18611953 if optiondict is not None:
18621954 self.entrywidget.configure(**optiondict)
@@ -1962,10 +2054,17 @@
19622054 self.status_msg.set('')
19632055 self.ctrvalue = tk.DoubleVar()
19642056 self.ctrvalue.set(0)
1965- self.statusbar = ttk.Label(parent, text='', textvariable=self.status_msg, relief=tk.RIDGE, anchor=tk.W)
19662057 self.progressmode = 'determinate'
1967- self.ctrprogress = ttk.Progressbar(parent, mode=self.progressmode, maximum=100,
1968- orient='horizontal', length=150, variable=self.ctrvalue)
2058+ if tkpane.use_ttk:
2059+ self.statusbar = ttk.Label(parent, text='', textvariable=self.status_msg, relief=tk.RIDGE, anchor=tk.W)
2060+ self.ctrprogress = ttk.Progressbar(parent, mode=self.progressmode, maximum=100,
2061+ orient='horizontal', length=150, variable=self.ctrvalue)
2062+ self.widget_type = "ttk"
2063+ else:
2064+ self.statusbar = tk.Label(parent, text='', textvariable=self.status_msg, relief=tk.RIDGE, anchor=tk.W)
2065+ self.ctrprogress = tk.Progressbar(parent, mode=self.progressmode, maximum=100,
2066+ orient='horizontal', length=150, variable=self.ctrvalue)
2067+ self.widget_type = "tk"
19692068 self.statusbar.grid(row=0, column=0, sticky=tk.EW)
19702069 self.ctrprogress.grid(row=0, column=1, sticky=tk.EW)
19712070 self.columnconfigure(0, weight=1)
@@ -2069,6 +2168,7 @@
20692168 msgframe.rowconfigure(0, weight=0)
20702169 msgframe.columnconfigure(0, weight=1)
20712170 msgframe.grid(row=0, column=0, pady=3, sticky=tk.EW)
2171+ self.widget_type = "ttk"
20722172 tableframe = ttk.Frame(master=self, padding="3 3 3 3")
20732173 # Create and configure the Treeview table widget and scrollbars.
20742174 self.tbl = ttk.Treeview(tableframe, columns=column_headers, selectmode="none", show="headings")
@@ -2176,6 +2276,7 @@
21762276 tkpane.TkPane.__init__(self, parent, "Table select", frame_config_opts(), frame_grid_opts())
21772277 self.datakeyname = "table_data"
21782278 self.datakeylist = [self.datakeyname]
2279+ self.widget_type = "ttk"
21792280 # Message frame and control.
21802281 self.msg_label = None
21812282 self.column_headers = []
@@ -2377,10 +2478,15 @@
23772478 opts = {} if optiondict is None else optiondict
23782479 self.datakeyname = "text" if key_name is None else key_name
23792480 self.datakeylist = [self.datakeyname]
2481+ self.widget_type = "tk"
23802482 self.textwidget = tk.Text(self, exportselection=False, **opts)
23812483 self.textwidget.bind("<Key>", self.check_entrychange)
2382- self.ysb = ttk.Scrollbar(self, orient='vertical', command=self.textwidget.yview)
2383- self.xsb = ttk.Scrollbar(self, orient='horizontal', command=self.textwidget.xview)
2484+ if tkpane.use_ttk:
2485+ self.ysb = ttk.Scrollbar(self, orient='vertical', command=self.textwidget.yview)
2486+ self.xsb = ttk.Scrollbar(self, orient='horizontal', command=self.textwidget.xview)
2487+ else:
2488+ self.ysb = tk.Scrollbar(self, orient='vertical', command=self.textwidget.yview)
2489+ self.xsb = tk.Scrollbar(self, orient='horizontal', command=self.textwidget.xview)
23842490 self.textwidget.configure(yscrollcommand=self.ysb.set, xscrollcommand=self.xsb.set)
23852491 if initial_text is not None:
23862492 self.replace_all(initial_text)
@@ -2521,8 +2627,12 @@
25212627
25222628 class GetUserDialog(Dialog):
25232629 def makebody(self, master):
2524- ttk.Label(master, text="User name:", width=12, anchor=tk.E).grid(row=0, column=0, sticky=tk.E, padx=3, pady=3)
2525- ttk.Label(master, text="Password:", width=12, anchor=tk.E).grid(row=1, column=0, sticky=tk.E, padx=3, pady=3)
2630+ if tkpane.use_ttk:
2631+ ttk.Label(master, text="User name:", width=12, anchor=tk.E).grid(row=0, column=0, sticky=tk.E, padx=3, pady=3)
2632+ ttk.Label(master, text="Password:", width=12, anchor=tk.E).grid(row=1, column=0, sticky=tk.E, padx=3, pady=3)
2633+ else:
2634+ tk.Label(master, text="User name:", width=12, anchor=tk.E).grid(row=0, column=0, sticky=tk.E, padx=3, pady=3)
2635+ tk.Label(master, text="Password:", width=12, anchor=tk.E).grid(row=1, column=0, sticky=tk.E, padx=3, pady=3)
25262636 self.e1 = tk.Entry(master, width=36)
25272637 self.e2 = tk.Entry(master, width=36, show="*")
25282638 self.e1.grid(row=0, column=1, sticky=tk.W, padx=3, pady=3)
@@ -2541,7 +2651,14 @@
25412651 self.userkeyname = "name"
25422652 self.passkeyname = "password"
25432653 self.datakeylist = [self.userkeyname, self.passkeyname]
2544- self.user_display = ttk.Entry(self, textvariable=self.user_var)
2654+ if tkpane.use_ttk:
2655+ self.user_display = ttk.Entry(self, textvariable=self.user_var)
2656+ self.user_button = ttk.Button(self, text='Change', width=8, command=self.set_user)
2657+ self.widget_type = "ttk"
2658+ else:
2659+ self.user_display = tk.Entry(self, textvariable=self.user_var)
2660+ self.user_button = tk.Button(self, text='Change', width=8, command=self.set_user)
2661+ self.widget_type = "tk"
25452662 self.user_display.config(state='readonly')
25462663 self.user_button = ttk.Button(self, text='Change', width=8, command=self.set_user)
25472664 self.user_label.grid(row=0, column=0, padx=6, pady=3, sticky=tk.EW)
@@ -2676,17 +2793,23 @@
26762793 def __init__(self, parent):
26772794 tkpane.TkPane.__init__(self, parent, "User credentials", config_opts=frame_config_opts(), grid_opts=frame_grid_opts())
26782795 self.user_validator = None
2679- self.user_label = ttk.Label(self, text='User name:', width=10, anchor=tk.E)
2680- self.pw_label = ttk.Label(self, text='Password:', width=10, anchor=tk.E)
26812796 self.user_var = tk.StringVar()
2682- self.user_var.trace("w", self.check_namechange)
26832797 self.pw_var = tk.StringVar()
2684- self.pw_var.trace("w", self.check_pwchange)
2798+ if tkpane.use_ttk:
2799+ self.user_label = ttk.Label(self, text='User name:', width=10, anchor=tk.E)
2800+ self.pw_label = ttk.Label(self, text='Password:', width=10, anchor=tk.E)
2801+ self.user_display = ttk.Entry(self, textvariable=self.user_var)
2802+ self.pw_display = ttk.Entry(self, textvariable=self.pw_var, show="*")
2803+ self.widget_type = "ttk"
2804+ else:
2805+ self.user_label = tk.Label(self, text='User name:', width=10, anchor=tk.E)
2806+ self.pw_label = tk.Label(self, text='Password:', width=10, anchor=tk.E)
2807+ self.user_display = tk.Entry(self, textvariable=self.user_var)
2808+ self.pw_display = tk.Entry(self, textvariable=self.pw_var, show="*")
2809+ self.widget_type = "tk"
26852810 self.userkeyname = "name"
26862811 self.passkeyname = "password"
26872812 self.datakeylist = [self.userkeyname, self.passkeyname]
2688- self.user_display = ttk.Entry(self, textvariable=self.user_var)
2689- self.pw_display = ttk.Entry(self, textvariable=self.pw_var, show="*")
26902813 self.user_label.grid(row=0, column=0, padx=6, pady=3, sticky=tk.EW)
26912814 self.pw_label.grid(row=1, column=0, padx=6, pady=3, sticky=tk.EW)
26922815 self.user_display.grid(row=0, column=1, padx=6, pady=3, sticky=tk.EW)
@@ -2696,6 +2819,8 @@
26962819 self.rowconfigure(1, weight=1)
26972820 parent.rowconfigure(0, weight=0)
26982821 parent.columnconfigure(0, weight=1)
2822+ self.user_var.trace("w", self.check_namechange)
2823+ self.pw_var.trace("w", self.check_pwchange)
26992824
27002825 #---------------------------------------------------------------------------
27012826 # Overrides of class methods.
diff -r d332105b830e -r f8511531f5f7 tkpane/tkpane.py
--- a/tkpane/tkpane.py Sat Mar 10 09:33:32 2018 -0800
+++ b/tkpane/tkpane.py Sat Mar 10 11:04:03 2018 -0800
@@ -27,7 +27,7 @@
2727 that pass specific data to allow communication between panes, and callback methods
2828 for reporting status and progress."""
2929
30-__version__ = "0.25.0"
30+__version__ = "0.26.0"
3131
3232
3333 try:
@@ -43,18 +43,23 @@
4343
4444
4545 #===============================================================================
46-# Module variables
46+# Configuration variables
47+#-------------------------------------------------------------------------------
48+
4749 # 'invalid_color' will be used as the background color of Entry or other
4850 # widgets when the data value is invalid. These colors will be used as the
4951 # default by new TkPane subclass objects when they are instantiated. The
5052 # colors for any pane subclass can be overridded using the 'set_invalid_color()
5153 # method. Tkinter (tk) and ttk widgets respond differently to these settings
5254 # when using the default themes on Linux and Windows.
53-#-------------------------------------------------------------------------------
5455 invalid_color = "#fff5ff"
5556 invalid_disabled_color = "#ece7ec"
5657 valid_color = "#ffffff"
5758
59+# Determine whether panes defined in tkpane.lib use ttk widgets if they exist
60+# (the default), or Tkinter widgets.
61+use_ttk = True
62+
5863
5964
6065
@@ -193,6 +198,7 @@
193198 if config_opts is not None:
194199 self.configure(**config_opts)
195200 self.original_values = {}
201+ self.widget_type = None
196202 self.grid(row=0, column=0, sticky=tk.NSEW)
197203 if grid_opts is not None:
198204 self.grid(**grid_opts)
@@ -318,7 +324,11 @@
318324 """
319325 if self.invalid_color is not None:
320326 wclass = widget.winfo_class()
321- if wclass in ("Text", "Listbox", "Spinbox"):
327+ if self.widget_type is not None:
328+ wtype = self.widget_type
329+ else:
330+ wtype = "tk" if wclass in ("Text", "Listbox", "Spinbox") else "ttk"
331+ if wtype == "tk":
322332 # tk widgets.
323333 col = self.valid_color if is_valid or not self.required else self.invalid_color
324334 try:
Show on old repository browser