Advertisement
gregwa

FCM #152 GUI File - depickle.py

Dec 6th, 2019
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 9.32 KB | None | 0 0
  1. #! /usr/bin/env python
  2. #  -*- coding: utf-8 -*-
  3. #
  4. # GUI module generated by PAGE version 4.27f
  5. #  in conjunction with Tcl version 8.6
  6. #    Dec 02, 2019 02:33:12 PM CST  platform: Linux
  7.  
  8. import sys
  9.  
  10. try:
  11.     import Tkinter as tk
  12. except ImportError:
  13.     import tkinter as tk
  14.  
  15. try:
  16.     import ttk
  17.     py3 = False
  18. except ImportError:
  19.     import tkinter.ttk as ttk
  20.     py3 = True
  21.  
  22. import depickle1_support
  23.  
  24. def vp_start_gui():
  25.     '''Starting point when module is the main routine.'''
  26.     global val, w, root
  27.     root = tk.Tk()
  28.     depickle1_support.set_Tk_var()
  29.     top = Toplevel1 (root)
  30.     depickle1_support.init(root, top)
  31.     root.mainloop()
  32.  
  33. w = None
  34. def create_Toplevel1(root, *args, **kwargs):
  35.     '''Starting point when module is imported by another program.'''
  36.     global w, w_win, rt
  37.     rt = root
  38.     w = tk.Toplevel (root)
  39.     depickle1_support.set_Tk_var()
  40.     top = Toplevel1 (w)
  41.     depickle1_support.init(w, top, *args, **kwargs)
  42.     return (w, top)
  43.  
  44. def destroy_Toplevel1():
  45.     global w
  46.     w.destroy()
  47.     w = None
  48.  
  49. class Toplevel1:
  50.     def __init__(self, top=None):
  51.         '''This class configures and populates the toplevel window.
  52.           top is the toplevel containing window.'''
  53.         _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
  54.         _fgcolor = '#000000'  # X11 color: 'black'
  55.         _compcolor = '#d9d9d9' # X11 color: 'gray85'
  56.         _ana1color = '#d9d9d9' # X11 color: 'gray85'
  57.         _ana2color = '#ececec' # Closest X11 color: 'gray92'
  58.         font9 = "-family {DejaVu Sans} -size 9"
  59.         self.style = ttk.Style()
  60.         if sys.platform == "win32":
  61.             self.style.theme_use('winnative')
  62.         self.style.configure('.',background=_bgcolor)
  63.         self.style.configure('.',foreground=_fgcolor)
  64.         self.style.map('.',background=
  65.             [('selected', _compcolor), ('active',_ana2color)])
  66.  
  67.         top.geometry("670x670+688+154")
  68.         top.minsize(1, 1)
  69.         top.maxsize(1905, 1050)
  70.         top.resizable(1, 1)
  71.         top.title("New Toplevel")
  72.         top.configure(highlightcolor="black")
  73.  
  74.         self.Entry1 = tk.Entry(top)
  75.         self.Entry1.place(relx=0.015, rely=0.112,height=31, relwidth=0.666)
  76.         self.Entry1.configure(background="white")
  77.         self.Entry1.configure(font="-family {DejaVu Sans Mono} -size 9")
  78.         self.Entry1.configure(selectbackground="#c4c4c4")
  79.         self.Entry1.configure(textvariable=depickle1_support.entry_var)
  80.  
  81.         self.btnFile = tk.Button(top)
  82.         self.btnFile.place(relx=0.682, rely=0.112, height=31, width=40)
  83.         self.btnFile.configure(activebackground="#f9f9f9")
  84.         self.btnFile.configure(command=depickle1_support.on_btnFile)
  85.         self.btnFile.configure(font="-family {Ubuntu} -size 11 -weight bold")
  86.         self.btnFile.configure(text='''...''')
  87.  
  88.         self.btnGo = tk.Button(top)
  89.         self.btnGo.place(relx=0.761, rely=0.112, height=29, width=101)
  90.         self.btnGo.configure(activebackground="#f9f9f9")
  91.         self.btnGo.configure(command=depickle1_support.on_btnGo)
  92.         self.btnGo.configure(font="-family {Ubuntu} -size 11 -weight bold")
  93.         self.btnGo.configure(text='''GO!''')
  94.  
  95.         self.Scrolledtext1 = ScrolledText(top)
  96.         self.Scrolledtext1.place(relx=0.015, rely=0.299, relheight=0.694
  97.                 , relwidth=0.978)
  98.         self.Scrolledtext1.configure(background="white")
  99.         self.Scrolledtext1.configure(font=font9)
  100.         self.Scrolledtext1.configure(insertborderwidth="3")
  101.         self.Scrolledtext1.configure(selectbackground="#c4c4c4")
  102.         self.Scrolledtext1.configure(wrap="none")
  103.  
  104.         self.btnExit = tk.Button(top)
  105.         self.btnExit.place(relx=0.881, rely=0.03, height=31, width=65)
  106.         self.btnExit.configure(activebackground="#f9f9f9")
  107.         self.btnExit.configure(command=depickle1_support.on_btnExit)
  108.         self.btnExit.configure(font="-family {Ubuntu} -size 11 -weight bold")
  109.         self.btnExit.configure(text='''EXIT!''')
  110.  
  111.         self.Label1 = tk.Label(top)
  112.         self.Label1.place(relx=0.036, rely=0.224, height=19, width=136)
  113.         self.Label1.configure(activebackground="#f9f9f9")
  114.         self.Label1.configure(anchor='e')
  115.         self.Label1.configure(font="-family {Ubuntu} -size 11 -weight bold")
  116.         self.Label1.configure(text='''Pickle Data Type:''')
  117.  
  118.         self.Label2 = tk.Label(top)
  119.         self.Label2.place(relx=0.245, rely=0.224, height=29, width=456)
  120.         self.Label2.configure(activebackground="#f9f9f9")
  121.         self.Label2.configure(borderwidth="3")
  122.         self.Label2.configure(font="-family {Ubuntu} -size 11 -weight bold -slant italic")
  123.         self.Label2.configure(relief="ridge")
  124.         self.Label2.configure(text='''Label''')
  125.         self.Label2.configure(textvariable=depickle1_support.pickleType)
  126.  
  127. # The following code is added to facilitate the Scrolled widgets you specified.
  128. class AutoScroll(object):
  129.     '''Configure the scrollbars for a widget.'''
  130.     def __init__(self, master):
  131.         #  Rozen. Added the try-except clauses so that this class
  132.         #  could be used for scrolled entry widget for which vertical
  133.         #  scrolling is not supported. 5/7/14.
  134.         try:
  135.             vsb = ttk.Scrollbar(master, orient='vertical', command=self.yview)
  136.         except:
  137.             pass
  138.         hsb = ttk.Scrollbar(master, orient='horizontal', command=self.xview)
  139.         try:
  140.             self.configure(yscrollcommand=self._autoscroll(vsb))
  141.         except:
  142.             pass
  143.         self.configure(xscrollcommand=self._autoscroll(hsb))
  144.         self.grid(column=0, row=0, sticky='nsew')
  145.         try:
  146.             vsb.grid(column=1, row=0, sticky='ns')
  147.         except:
  148.             pass
  149.         hsb.grid(column=0, row=1, sticky='ew')
  150.         master.grid_columnconfigure(0, weight=1)
  151.         master.grid_rowconfigure(0, weight=1)
  152.         # Copy geometry methods of master  (taken from ScrolledText.py)
  153.         if py3:
  154.             methods = tk.Pack.__dict__.keys() | tk.Grid.__dict__.keys() \
  155.                   | tk.Place.__dict__.keys()
  156.         else:
  157.             methods = tk.Pack.__dict__.keys() + tk.Grid.__dict__.keys() \
  158.                   + tk.Place.__dict__.keys()
  159.         for meth in methods:
  160.             if meth[0] != '_' and meth not in ('config', 'configure'):
  161.                 setattr(self, meth, getattr(master, meth))
  162.  
  163.     @staticmethod
  164.     def _autoscroll(sbar):
  165.         '''Hide and show scrollbar as needed.'''
  166.         def wrapped(first, last):
  167.             first, last = float(first), float(last)
  168.             if first <= 0 and last >= 1:
  169.                 sbar.grid_remove()
  170.             else:
  171.                 sbar.grid()
  172.             sbar.set(first, last)
  173.         return wrapped
  174.  
  175.     def __str__(self):
  176.         return str(self.master)
  177.  
  178. def _create_container(func):
  179.     '''Creates a ttk Frame with a given master, and use this new frame to
  180.    place the scrollbars and the widget.'''
  181.     def wrapped(cls, master, **kw):
  182.         container = ttk.Frame(master)
  183.         container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
  184.         container.bind('<Leave>', lambda e: _unbound_to_mousewheel(e, container))
  185.         return func(cls, container, **kw)
  186.     return wrapped
  187.  
  188. class ScrolledText(AutoScroll, tk.Text):
  189.     '''A standard Tkinter Text widget with scrollbars that will
  190.    automatically show/hide as needed.'''
  191.     @_create_container
  192.     def __init__(self, master, **kw):
  193.         tk.Text.__init__(self, master, **kw)
  194.         AutoScroll.__init__(self, master)
  195.  
  196. import platform
  197. def _bound_to_mousewheel(event, widget):
  198.     child = widget.winfo_children()[0]
  199.     if platform.system() == 'Windows' or platform.system() == 'Darwin':
  200.         child.bind_all('<MouseWheel>', lambda e: _on_mousewheel(e, child))
  201.         child.bind_all('<Shift-MouseWheel>', lambda e: _on_shiftmouse(e, child))
  202.     else:
  203.         child.bind_all('<Button-4>', lambda e: _on_mousewheel(e, child))
  204.         child.bind_all('<Button-5>', lambda e: _on_mousewheel(e, child))
  205.         child.bind_all('<Shift-Button-4>', lambda e: _on_shiftmouse(e, child))
  206.         child.bind_all('<Shift-Button-5>', lambda e: _on_shiftmouse(e, child))
  207.  
  208. def _unbound_to_mousewheel(event, widget):
  209.     if platform.system() == 'Windows' or platform.system() == 'Darwin':
  210.         widget.unbind_all('<MouseWheel>')
  211.         widget.unbind_all('<Shift-MouseWheel>')
  212.     else:
  213.         widget.unbind_all('<Button-4>')
  214.         widget.unbind_all('<Button-5>')
  215.         widget.unbind_all('<Shift-Button-4>')
  216.         widget.unbind_all('<Shift-Button-5>')
  217.  
  218. def _on_mousewheel(event, widget):
  219.     if platform.system() == 'Windows':
  220.         widget.yview_scroll(-1*int(event.delta/120),'units')
  221.     elif platform.system() == 'Darwin':
  222.         widget.yview_scroll(-1*int(event.delta),'units')
  223.     else:
  224.         if event.num == 4:
  225.             widget.yview_scroll(-1, 'units')
  226.         elif event.num == 5:
  227.             widget.yview_scroll(1, 'units')
  228.  
  229. def _on_shiftmouse(event, widget):
  230.     if platform.system() == 'Windows':
  231.         widget.xview_scroll(-1*int(event.delta/120), 'units')
  232.     elif platform.system() == 'Darwin':
  233.         widget.xview_scroll(-1*int(event.delta), 'units')
  234.     else:
  235.         if event.num == 4:
  236.             widget.xview_scroll(-1, 'units')
  237.         elif event.num == 5:
  238.             widget.xview_scroll(1, 'units')
  239.  
  240. if __name__ == '__main__':
  241.     vp_start_gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement