示例#1
0
    def __init__(self):
        # init base classes
        MyLoggingBase.__init__(self, name='app')
        tk.Tk.__init__(self)

        # load settings
        self.settings = self.DEFAULT_SETTINGS
        for k, v in self.read_file_key_values(
                self.get_resource_fd('settings.ini')).items():
            try:
                t = float(v)  # is float?
            except ValueError:
                t = v  # must be string
            else:
                if t == int(t): t = int(t)  # is int?
            self.settings[k] = t

        # setup application window
        self.title(main.__title__)  # set title
        self.iconname(main.__title__)
        self.attributes('-topmost', True)  # always on top
        self.minsize(width=255,
                     height=1)  # set min width so we see full title!
        self.resizable(width=False, height=False)  # not resizable
        self.protocol("WM_DELETE_WINDOW", self.on_quit)  # bind ALT+F4

        # add MenuBar
        menu_bar = MyTkMenuBar(self)
        self.config(menu=menu_bar)  #attach to frame

        # add StatusBar
        self.status_bar = MyTkStatusBar(self)
        self.status_bar.pack(side=tk.BOTTOM, fill=tk.X)

        # add MainFrame
        self.main_frame = MyTkMainFrame(self)
        self.main_frame.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)

        # Remain invisible while we resize
        #self.withdraw() # invisible #self.transient(self.master)
        #self.transient(self.master)
        #self.update_idletasks() # update geometry

        # set title bar icon (causes geo and to show)
        try:
            self.iconbitmap(self.get_resource_fd('python-icon.ico'))
        except tk.TclError:
            pass  # in ubuntu: _tkinter.TclError: bitmap /.../... not defined
        #         self.logger.debug('%r %r %r (%r,%r) -- (%r,%r) %r %r',
        #                           self.winfo_ismapped(),
        #                           self.winfo_rootx(),
        #                           self.winfo_rooty(),
        #                           self.winfo_screenwidth(),
        #                           self.winfo_screenheight(),
        #                           self.winfo_width(),
        #                           self.winfo_height(),
        #                           self.winfo_reqwidth(),
        #                           self.winfo_reqheight()
        #                           )
        self.set_status('Ready')  # update status
示例#2
0
 def __init__(self,parent,title=None,
              inputs=None,
              name=None):
     MyLoggingBase.__init__(self,name=name)
     self.__inputs = inputs.copy()
     
     Dialog.__init__(self,parent=parent,title=title)
示例#3
0
    def __init__(self, parent):
        MyLoggingBase.__init__(self, name='mainframe')
        ttk.Frame.__init__(self, parent)

        #=======================================================================
        # Frame
        #=======================================================================
        # buttons
        self.btn_record = ttk.Button(self,
                                     text='Record (Ctrl+Shift+R)',
                                     command=self.record)
        self.btn_record.grid(row=0, column=0, sticky=tk.N + tk.E + tk.S + tk.W)
        self.bind_all('<Control-Shift-R>', self.start_recording)
        self.bind_all('<<stop-recording>>', self.stop_recording)
        self.btn_run = ttk.Button(self, text='Run (Ctrl+R)', command=self.run)
        self.btn_run.grid(row=0, column=1, sticky=tk.N + tk.E + tk.S + tk.W)
        self.bind_all('<Control-r>', self.run)

        self.columnconfigure(0, weight=1)  # so resize will fit
        self.columnconfigure(1, weight=1)  # so resize will fit

        # next action
        lf = ttk.LabelFrame(self, text='Next Action:')
        self.__next_action = tk.StringVar(value='', name='next action')
        ttk.Label(lf,
                  textvariable=self.__next_action,
                  anchor=tk.W,
                  justify=tk.LEFT,
                  width=33).grid(row=1,
                                 column=0,
                                 columnspan=2,
                                 sticky=tk.N + tk.E + tk.S + tk.W)
        lf.columnconfigure(0, weight=1)  # so resize will fit
        lf.grid(row=1, columnspan=2, sticky=tk.N + tk.E + tk.S + tk.W)

        # console
        lf = ttk.LabelFrame(self, text='Console:')
        # http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-Treeview.html
        self.list_ids = list()
        self.list_actions = ttk.Treeview(lf,
                                         height=self.LB_MAX_SIZE,
                                         selectmode='none',
                                         show='tree',
                                         takefocus=False)
        # setup columns
        self.list_actions['columns'] = ('ind', 'text')
        self.list_actions.column('#0', minwidth=0, width=0, stretch=False)
        self.list_actions.column('ind', minwidth=33, width=33, stretch=False)
        self.list_actions.column('text', minwidth=30, width=30, stretch=True)
        self.list_actions.pack(side=tk.LEFT, fill=tk.BOTH, expand=1)
        # add vertical scroll bar https://stackoverflow.com/questions/41877848/python-treeview-scrollbar
        vsb = ttk.Scrollbar(lf,
                            orient='vertical',
                            command=self.list_actions.yview)
        vsb.pack(side=tk.LEFT, fill=tk.Y)
        self.list_actions.config(yscrollcommand=vsb.set)

        #lf.columnconfigure(0, weight=1) # so resize will fit
        lf.grid(row=2, columnspan=2, sticky=tk.N + tk.E + tk.S + tk.W)
示例#4
0
    def __init__(self, root, actions_queue, *args, **keys):
        MyLoggingBase.__init__(self, *args, **keys)
        Thread.__init__(self, *args, **keys)

        self.__root = root
        self.__queue = actions_queue
        self.__time_lock = Lock()
        self.__key_lock = Lock()
示例#5
0
    def __init__(self, root, actions_queue, actions, settings, *args, **keys):
        MyLoggingBase.__init__(self, *args, **keys)
        Thread.__init__(self, *args, **keys)

        self.__root = root
        self.__evt = Event()
        self.__queue = actions_queue
        self.__actions = actions
        self.__settings = settings
示例#6
0
    def __init__(self, parent):
        MyLoggingBase.__init__(self, name='statusbar')
        ttk.Frame.__init__(self, parent)

        self.vars = []  # if we want multiple labels
        self.add_section()  # add status section
示例#7
0
    def __init__(self, parent):
        MyLoggingBase.__init__(self, name='menubar')
        tk.Menu.__init__(self, parent)

        # MenuBar - File
        file_menu = tk.Menu(self, tearoff=0)
        file_menu.add_command(label='New',
                              command=self.check_in_menu(self.new),
                              underline=0,
                              accelerator='Ctrl+N')
        self.bind_all('<Control-n>', self.check_in_menu(self.new))
        file_menu.add_command(label='Open...',
                              command=self.check_in_menu(self.open),
                              underline=0,
                              accelerator='Ctrl+O')
        self.bind_all('<Control-o>', self.check_in_menu(self.open))
        file_menu.add_separator()
        file_menu.add_command(label='Save',
                              command=self.check_in_menu(self.save),
                              underline=0,
                              accelerator='Ctrl+S')
        self.bind_all('<Control-s>', self.check_in_menu(self.save))
        file_menu.add_command(label='Save As ...',
                              command=self.check_in_menu(self.saveAs),
                              accelerator='Ctrl+Shift+S')
        self.bind_all('<Control-Shift-S>', self.check_in_menu(self.saveAs))
        file_menu.add_separator()
        file_menu.add_command(label='Exit',
                              command=self.check_in_menu(parent.on_quit),
                              underline=1,
                              accelerator='Ctrl+Q')
        self.bind_all('<Control-q>', self.check_in_menu(parent.on_quit))
        self.add_cascade(label='File', menu=file_menu, underline=0)

        # MenuBar - Edit
        edit_menu = tk.Menu(self, tearoff=0)
        edit_menu.add_command(label='Text Editor...',
                              command=self.check_in_menu(
                                  parent.not_implemented),
                              underline=0,
                              accelerator='Ctrl+T')
        self.bind_all('<Control-t>',
                      self.check_in_menu(parent.not_implemented))
        edit_menu.add_separator()
        edit_menu.add_command(label='Options',
                              command=self.check_in_menu(self.edit_options),
                              underline=0,
                              accelerator='')
        self.add_cascade(label='Edit', menu=edit_menu, underline=0)

        # MenuBar - Tools
        tool_menu = tk.Menu(self, tearoff=0)
        tool_menu.add_command(label='Test Color...',
                              command=self.tool_test_color,
                              underline=0,
                              accelerator='Shift+T')
        self.bind_all('<Shift-T>', self.tool_test_color)
        self.add_cascade(label='Tools', menu=tool_menu, underline=0)

        # MenuBar - Help
        help_menu = tk.Menu(self, tearoff=0)
        help_menu.add_command(label='About',
                              command=self.show_about,
                              underline=0)
        self.add_cascade(label='Help', menu=help_menu, underline=0)
示例#8
0
 def __str__(self, *args, **kwargs):
     """see to_str"""
     return MyLoggingBase.__str__(self, *args, **kwargs)
示例#9
0
    def __init__(self, *args,**keys):
        MyLoggingBase.__init__(self,*args,**keys)

        list.__init__(self,*args,**keys)