def __init__(self, master, max_lines, *args, **kwargs): '''Override of ttk.Frame's initialization function''' # Initialize root frame ttk.Frame.__init__(self, master, *args, **kwargs) self.columnconfigure(0, weight=1) # Entry widget self.columnconfigure(1, weight=0) # AutoScrollbar self.rowconfigure(0, weight=1) self.MAX_LINES = max_lines # Max number of lines entry will resize to # Initialize multiline entry widget self.entry = me.MultilineEntry(self, self.MAX_LINES, font=Fonts.get('EntryText'), relief=tk.FLAT, wrap='word', highlightbackground="light grey", highlightthickness=2, height=1) self.entry.grid(column=0, row=0, sticky=tk.EW) # Initialize scrollbar self.vsb = asb.AutoScrollbar(self, 1, 0, orient=tk.VERTICAL) self.entry.configure(yscrollcommand=self.vsb.set) self.bind('<Configure>', self.entry.on_configure) self.entry.bind('<Return>', self.__on_enter) self.entry.bind('<Shift-Return>', self.__on_newline)
def __init__(self, master, timestamp_lbl, *args, **kwargs): ttk.Frame.__init__(self, master, *args, **kwargs) self.author_guid = b'' self.author_name = '' self.is_host = False self.visible = False self.wtype = WidgetType.WTYPE_ROOT_CONTAINER self.depth = 0 # Initialize root grid self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=0) self.rowconfigure(1, weight=0) # Main message area # NOTE Default height to 1 so that it does not attempt to fill up # available space causing screen flicker and grid calculation lag self.text = ResizableText(self, font=Fonts.get('MessageText'), relief=tk.FLAT, wrap=tk.WORD, highlightbackground="light grey", highlightthickness=2, height=1) self.text.wtype = WidgetType.WTYPE_LEAF self.text.depth = self.text.master.depth + 1 # Frame containing author, timestamp, etc... self.metadata_frame = ttk.Frame(self) self.metadata_frame.wtype = WidgetType.WTYPE_LEAF self.metadata_frame.depth = self.metadata_frame.master.depth + 1 self.metadata_frame.grid(column=0, row=0, sticky=tk.EW) # Author ID self.author_lbl = ttk.Label(self.metadata_frame) self.author_lbl.wtype = WidgetType.WTYPE_LEAF self.author_lbl.depth = self.author_lbl.master.depth + 1 # Timestamp self.timestamp_lbl = ttk.Label(self.metadata_frame, text=timestamp_lbl, style='MsgTimestamp.TLabel') self.timestamp_lbl.wtype = WidgetType.WTYPE_LEAF self.timestamp_lbl.depth = self.timestamp_lbl.master.depth + 1
def __init__(self, master, in_q, *args, **kwargs): ''' :param in_q: Queue for data coming from backend to GUI ''' # Initialize root window ttk.Frame.__init__(self, master, *args, **kwargs) master.title(f'Endpoints') master.configure(background='gray95') # Configure fonts Fonts.init() # Configure Styles style = ttk.Style() # MessageFrame styles style.configure('MsgAuthor.TLabel', foreground='dark gray', font=Fonts.get('MessageAuthor')) style.configure('MsgAuthorHost.TLabel', foreground='tomato', font=Fonts.get('MessageAuthor')) style.configure('MsgTimestamp.TLabel', foreground='gray', font=Fonts.get('MessageTimestamp')) style.configure('EntryArea.TFrame', background='gray95') style.configure('EmptyArea.TLabel', foreground='gray', anchor=tk.CENTER, font=Fonts.get('EmptyArea')) style.configure('Sidebar.TFrame', background='white') style.configure('Listbox.TFrame', background='white') style.configure('ConnectionWidget.TFrame', background='white') style.configure('Unselected.ConnectionWidget.TFrame', background='white') style.configure('Selected.ConnectionWidget.TFrame', background='light sky blue') style.configure('ConnectionWidget.TLabel', background='white', anchor=tk.W, padding=(5, 15)) style.configure('Unselected.ConnectionWidget.TLabel', background='white') style.configure('Selected.ConnectionWidget.TLabel', background='light sky blue') style.configure('AboutMain.TLabel', font=Fonts.get('AboutMain')) self.poll_id = None # Configure root window master.eval('tk::PlaceWindow %s center' % master.winfo_toplevel()) # master.protocol('WM_DELETE_WINDOW', self.__window_close_callback) # Initialize root window grid master.columnconfigure(0, weight=1) master.rowconfigure(0, weight=1) master.minsize(width=600, height=300) # Root frame grid self.columnconfigure(0, weight=1) self.rowconfigure(0, weight=1) # Place root frame self.grid(column=0, row=0, sticky=tk.NSEW) # Configure window menu self.menu = mb.MenuBar(master, master.destroy) master.configure(menu=self.menu) # Paned window to hold the conversation area self.paned_window = ttk.PanedWindow(self, orient=tk.HORIZONTAL) self.paned_window.grid(column=0, row=0, sticky=tk.NSEW) # Configure main area self.convo_mgr = cf.ConversationFrame(self) # Configure side bar self.side_panel = sb.SideBar(self, self.convo_mgr.add_conversation, self.convo_mgr.activate_conversation, self.convo_mgr.remove_conversation, style='Sidebar.TFrame') # Place sidebar in left pane and conversation area in right pane self.paned_window.add(self.side_panel) self.paned_window.add(self.convo_mgr) # Place window in the center of the screen self.master.update_idletasks() w = self.master.winfo_width() h = self.master.winfo_height() wscreen = self.winfo_screenwidth() hscreen = self.winfo_screenheight() x = (wscreen / 2) - (w / 2) y = (hscreen / 2) - (h / 2) self.master.geometry(f'{int(w)}x{int(h)}+{int(x)}+{int(y)}') # Begin polling of queues self.__poll(in_q)