Advertisement
gregwa

ttkdemo_support.py

Aug 26th, 2019
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.51 KB | None | 0 0
  1. #! /usr/bin/env python
  2. #  -*- coding: utf-8 -*-
  3. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. # ttkdemo_support.py
  5. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  6. # Written by G.D. Walters for FCM 149 - September 2019
  7. # Submitted to the public domain - all rights reserved
  8. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. # Support module generated by PAGE version 4.25
  10. #  in conjunction with Tcl version 8.6
  11. #    Aug 25, 2019 07:48:16 PM CDT  platform: Linux
  12.  
  13. import sys
  14.  
  15. try:
  16.     import Tkinter as tk
  17. except ImportError:
  18.     import tkinter as tk
  19.  
  20. try:
  21.     import ttk
  22.     py3 = False
  23. except ImportError:
  24.     import tkinter.ttk as ttk
  25.     py3 = True
  26.  
  27.  
  28. def set_Tk_var():
  29.     global tch46
  30.     tch46 = tk.StringVar()
  31.     global combobox
  32.     combobox = tk.StringVar()
  33.     global selectedButton
  34.     selectedButton = tk.StringVar()
  35.     global EntryVar
  36.     EntryVar = tk.StringVar()
  37.     global LabelVar
  38.     LabelVar = tk.StringVar()
  39.     LabelVar.set('')
  40.  
  41.  
  42. def on_rbClick():
  43.     print('ttkdemo_support.on_rbClick')
  44.     sys.stdout.flush()
  45.     print("RadioButton {0} clicked".format(selectedButton.get()))
  46.     style = ttk.Style()
  47.     selected = selectedButton.get()
  48.     style.theme_use(style.theme_names()[int(selected)])
  49.  
  50.  
  51. def on_btnExit():
  52.     print('ttkdemo_support.on_btnExit')
  53.     sys.stdout.flush()
  54.     destroy_window()
  55.  
  56.  
  57. def init(top, gui, *args, **kwargs):
  58.     global w, top_level, root
  59.     w = gui
  60.     top_level = top
  61.     root = top
  62.     # ======================================================
  63.     # Our init code starts here
  64.     # ======================================================
  65.     setup_styles()
  66.  
  67.  
  68. def setup_styles():
  69.     rblist = [w.TRadiobutton1, w.TRadiobutton2, w.TRadiobutton3,
  70.               w.TRadiobutton4, w.TRadiobutton5, w.TRadiobutton6,
  71.               w.TRadiobutton7]
  72.  
  73.     s = ttk.Style()
  74.     cntr = 0
  75.  
  76.     def clear_radio_buttons():
  77.         for i in range(7):
  78.             rblist[i].configure(text='')
  79.             rblist[i].configure(state='disabled')
  80.  
  81.     clear_radio_buttons()
  82.  
  83.     for i in s.theme_names():
  84.         print(i)
  85.         rblist[cntr].configure(text=i)
  86.         rblist[cntr].configure(state='normal')
  87.         cntr += 1
  88.     w.TProgressbar1.config(mode='indeterminate')
  89.     w.TProgressbar1.start()
  90.  
  91.  
  92. def destroy_window():
  93.     # Function which closes the window.
  94.     global top_level
  95.     top_level.destroy()
  96.     top_level = None
  97.  
  98.  
  99. if __name__ == '__main__':
  100.     import ttkdemo
  101.     ttkdemo.vp_start_gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement