Advertisement
AceScottie

W_SW.py

Nov 15th, 2018
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.89 KB | None | 0 0
  1. from Tkinter import *
  2. from aceutil import Log, TkUtils
  3. import traceback, os, sys
  4.  
  5. ##FIXES--------------------------------------------------------
  6. if os.name == 'nt': #windows fix
  7.     import win32api, win32con
  8. if getattr(sys, 'frozen', False): #windows path fix
  9.     os.chdir(sys._MEIPASS)
  10.     exe_path = os.path.dirname(sys.executable)
  11. elif __file__:
  12.     exe_path = os.path.dirname(__file__)
  13. def retag(tag, *args): #for bind_class functions for multiple objects bound to same class
  14.     for widget in args:
  15.         widget.bindtags((tag,) + widget.bindtags())
  16. def no(): #fix for cButton function, used as a default command
  17.     pass
  18. #--------------------------------------------------------------
  19.  
  20. class GUI:
  21.     def __init__(self):
  22.         self.log = Log() ##uses the log file system from aceutil
  23.         self.root = Tk() ##basic tkinter root window
  24.         self.atk = TkUtils(self.log, self.root) ##Tkinter utilities
  25.         self.active_window = None ##holder for the active window
  26.  
  27.     def create_window(self, event, title="", height=400, width=400): #create overlayed canvas
  28.         try:
  29.             self.active_window = self.atk.overlay(self.root, event, title, height=height, width=width)
  30.             return "break"
  31.         except Exception as err:
  32.             exc_type, exc_obj, exc_tb = sys.exc_info()
  33.             self.log.error("create_window failed\n%s, %s, %s, %s" %(err, exc_type, exc_obj, traceback.print_tb(exc_tb)))
  34.     def clear_window(self, event): #clear overlayed canvas
  35.         try:
  36.             if self.active_window != None:
  37.                 self.active_window.destroy()
  38.             return "break"
  39.         except Exception as err:
  40.             exc_type, exc_obj, exc_tb = sys.exc_info()
  41.             self.log.error("clear_window failed\n%s, %s, %s, %s" %(err, exc_type, exc_obj, traceback.print_tb(exc_tb)))
  42.  
  43. def basic_movable_window(self, event):
  44.         try:
  45.             self.create_window(event, title="Some Title", height=250, width =250)
  46.             overlay = self.active_window
  47.             holder= self.atk..cFrame(overlay, padx=5, pady=5)
  48.             ## you frame to use is holder
  49.         except Exception as err:
  50.             exc_type, exc_obj, exc_tb = sys.exc_info()
  51.             self.log.error("basic_movable_windowfailed\n%s, %s, %s, %s" %(err, exc_type, exc_obj, traceback.print_tb(exc_tb)))
  52.  
  53.  
  54.  
  55. def basic_movable_scroll_window(self, event): #interface for the notification box
  56.         try:
  57.             self.active_window = self.atk.overlay(self.root, title="Some Title", height=250, width =250)
  58.             overlay = self.active_window
  59.             infill = self.atk.cFrame(overlay, bg="white", padx=5, pady=5, fill=BOTH, expand=1)
  60.             scroll, can3 = self.atk.scrollable_area2(infill)
  61.             self.root.update_idletasks()
  62.             self.root.update()
  63.             self.atk.set_pos(overlay)
  64.             holder = self.atk.cFrame(scroll, side=TOP, bg="white", padx=5, pady=5, fill=BOTH, expand=1)
  65.             ## you frame to use is holder
  66.             ##Your code goes Here
  67.         except Exception as err:
  68.             exc_type, exc_obj, exc_tb = sys.exc_info()
  69.             self.log.error("basic_movable_scroll_windowfailed\n%s, %s, %s, %s" %(err, exc_type, exc_obj, traceback.print_tb(exc_tb)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement