def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) logger.info("Player Title page initialize") s = ttk.Style(self) self.video_mode = False self.title_video_str = Data_Flow_Player.get_title_video() print(type(parent).__name__) self.parent_window = parent self.pen_color = 'bisque2' self.old_x, self.old_y = None, None self.configure(background='deepskyblue4') self.quoteframe = tk.Frame(self) self.quoteframe.configure(background='deepskyblue4') self.quoteframe.pack(fill=tk.X, side=tk.TOP, anchor=tk.CENTER) self.quote_text = Data_Flow_Player.get_Quote() self.quote_textwidget = tk.Text(self.quoteframe, borderwidth=0, highlightthickness=0, relief=tk.FLAT, wrap=tk.WORD, font=('helvetica', 14, 'bold'), bd=2, height=2, foreground='white', background='deepskyblue4') self.labelframeone = ttk.Labelframe(self, text="Introduction", relief=tk.RIDGE, style='Red.TLabelframe') self.counter = 0 pageutils.animate_text(self.quoteframe, self.quote_text, self.counter, self.quote_textwidget, len(self.quote_text) - 1) self.quote_textwidget.pack(pady=5, side=tk.TOP, anchor=tk.CENTER) self.buttonimage = tk.PhotoImage(file="../images/speaker.png") self.quote_audio_button = ttk.Button( self.quoteframe, text="hello", image=self.buttonimage, command=lambda: self.play_quote_audio(self.quote_text), style='Green.TButton') self.quote_audio_button.pack(padx=100, side=tk.TOP) self.quote_audio_button.tooltip = tooltip.ToolTip( self.quote_audio_button, "Read Aloud") self.title_intro()
def __init__(self, textLabel=None, callBack=None, cbparams=[], rect=pygame.Rect(0, 0, 100, 50), color=(152, 172, 186), textColor=(0, 0, 0), tooltipName="", tooltipText=""): self.textLabel = textLabel self.textRect = self.textLabel.get_rect() self.rect = rect self.color = color self.textColor = textColor self.cb = callBack self.textRect.center = self.rect.center self.cbparams = cbparams self.tooltip = tooltip.ToolTip(tooltipName, tooltipText, (0, 0))
def notes_display(self): logger.info("Player Title page notes_display") video_notes_info = Data_Flow_Player.get_Running_Notes() video_notes = video_notes_info[0] self.text_frame = tk.Frame(self, background="deepskyblue4") self.text_width = int(self.winfo_width() / 30) self.text_height = int(self.winfo_height() / 35) self.video_note_text = tk.Text(self.text_frame, pady=10, borderwidth=0, highlightthickness=0, relief=tk.SUNKEN, wrap=tk.WORD, font=("helvetica", 16, 'bold'), width=self.text_width, height=self.text_height, foreground="snow", background='deepskyblue4') self.button_notes_image = tk.PhotoImage(file="../images/speaker.png") self.intro_text_speaker = ttk.Button( self.text_frame, text="hello", image=self.button_notes_image, command=lambda: self.play_quote_audio(video_notes), style='Green.TButton') pageutils.animate_text(self, video_notes, 0, self.video_note_text, len(video_notes) - 1) self.intro_text_speaker.tooltip = tooltip.ToolTip( self.intro_text_speaker, "Read Aloud") self.intro_text_speaker.pack(side=tk.BOTTOM) self.scrollbar = ttk.Scrollbar(self.text_frame) self.video_note_text.config(yscrollcommand=self.scrollbar.set) self.scrollbar.pack(side=tk.RIGHT, fill=tk.Y) self.scrollbar.config(command=self.video_note_text.yview, style='TScrollbar') self.text_frame.pack(side=tk.RIGHT) self.video_note_text.pack(padx=50)
def __init__(self): G.player = self self.inventory = playerinventory.PlayerInventory() self.dimension = None self.name = "mcpython_test_player" self.chat = chat.chat() G.inventoryhandler.show_inventory(self.inventory.id) self.gamemode = config.DEFAULT_GAMEMODE self.selectedinventoryslot = 0 self.movingslot = None self.movingslotstart = None self.entity = PlayerEntity() self.tooltip = tooltip.ToolTip() self.active_tooltip = False self.tooltipslot = None self.checkinventorysforslots = [self.inventory.inventorys[0]] self.harts = 20 self.__oldharts = None self.hartsprites = [] self.hartimages = [ pyglet.image.load( G.local + "/assets/minecraft/textures/gui/icons/hards_full.png"), pyglet.image.load( G.local + "/assets/minecraft/textures/gui/icons/hards_half.png"), ] self.drawn_sprites = 0 for i in range(10): self.hartsprites.append(pyglet.sprite.Sprite(self.hartimages[0])) self.hartsprites[-1].position = ( self.inventory.inventorys[0].getBasePosition()[0] + i * 17, 70, ) self.updateHarts() for k in config.AdvancedVanilla.START_INVENTORY.keys(): self.addToInventory(k, config.AdvancedVanilla.START_INVENTORY[k])
def __init__(self, master): frameTop = Frame(master) frameTop.grid(row=0, column=0, columnspan=3, padx=10) frameBot = Frame(master) frameBot.grid(row=2, column=0, sticky=W, padx=10, pady=5) frameLabe = Frame(master) frameLabe.grid(row=1, column=0, sticky=W, padx=10) self.label1 = Label(frameTop, text="User Name:") self.label1.pack(side=LEFT) self.ttip_label1 = tooltip.ToolTip(self.label1, "This field may be left blank") self.username_text = StringVar() self.entry1 = Entry(frameTop, textvariable=self.username_text) self.entry1.pack(side=LEFT, padx=2) self.ttip_entry1 = tooltip.ToolTip(self.entry1, "This field may be left blank") self.label2 = Label(frameTop, text="Image Url:") self.label2.pack(side=LEFT) self.ttip_label2 = tooltip.ToolTip(self.label2, "This field may be left blank") self.imgurl_text = StringVar() self.entry2 = Entry(frameTop, textvariable=self.imgurl_text) self.entry2.pack(side=LEFT, padx=2) self.ttip_entry2 = tooltip.ToolTip(self.entry2, "This field may be left blank") self.mbox = Text(frameBot, maxundo=10, height=10, width=50, wrap=WORD) self.mbox.pack(side=LEFT) self.ttip_mbox = tooltip.ToolTip(self.mbox, "This field is required") self.label3 = Label(frameLabe, text="Message:") self.label3.pack(side=LEFT) self.ttip_label3 = tooltip.ToolTip(self.label3, "This field is required")
def fill_canvas_frame(self, width, height): logger.info("Experiment Page - fill_canvas_frame") self.button_frame = tk.Frame(self.labelframeone, background="deepskyblue4") self.add_image_icon = tk.PhotoImage(file="../images/image_open.png") self.image_button = ttk.Button(self.button_frame, text='Add Image', image=self.add_image_icon, command=self.use_image, style='Green.TButton') self.image_button.grid(row=0, column=0, padx=5) self.image_button.tooltip = tooltip.ToolTip(self.image_button, "Open an image file") self.move_image_icon = tk.PhotoImage(file="../images/image_move.png") self.image_act_button = ttk.Button(self.button_frame, text='Move Image', image=self.move_image_icon, command=self.use_image_act, style='Green.TButton') self.image_act_button.grid(row=0, column=1, padx=5) self.image_act_button.tooltip = tooltip.ToolTip( self.image_act_button, "Enable Moving of Images") self.pen_image_icon = tk.PhotoImage(file="../images/pen_brush.png") self.pen_button = ttk.Button(self.button_frame, text='Pen', image=self.pen_image_icon, command=self.use_pen, style='Green.TButton') self.pen_button.grid(row=0, column=2, padx=5) self.pen_button.tooltip = tooltip.ToolTip(self.pen_button, "Draw with a Pen") self.color_image_icon = tk.PhotoImage(file="../images/color_pal.png") self.color_button = ttk.Button(self.button_frame, text='Color', image=self.color_image_icon, command=self.choose_color, style='Green.TButton') self.color_button.grid(row=0, column=3, padx=5) self.color_button.tooltip = tooltip.ToolTip(self.color_button, "Choose a Color") self.eraser_image_icon = tk.PhotoImage(file="../images/erase.png") self.eraser_button = ttk.Button(self.button_frame, text='Eraser', image=self.eraser_image_icon, command=self.use_eraser, style='Green.TButton') self.eraser_button.grid(row=0, column=4, padx=5) self.eraser_button.tooltip = tooltip.ToolTip(self.eraser_button, "Erase Drawing") self.choose_size_button = tk.Scale(self.button_frame, orient=tk.HORIZONTAL, from_=1, to=10, background='deepskyblue4', foreground='white') self.choose_size_button.tooltip = tooltip.ToolTip( self.choose_size_button, "Line Size of the Pen") self.clear_image_icon = tk.PhotoImage(file="../images/cls.png") self.clear_button = ttk.Button(self.button_frame, text='Clear', image=self.clear_image_icon, command=self.clear, style='Green.TButton') self.clear_button.tooltip = tooltip.ToolTip(self.clear_button, "Clear Entire Canvas") self.buttonimage = tk.PhotoImage(file="../images/save.png") self.image_save_button = ttk.Button( self.button_frame, text="Save Canvas", image=self.buttonimage, command=lambda: self.save_image_window(self.canvas_experiment, random.randint(0, 100)), style='Green.TButton') self.image_save_button.tooltip = tooltip.ToolTip( self.image_save_button, "Save Canvas to view in Lesson Notes\n(Moving to Next Page also saves the canvas)" ) self.choose_size_button.grid(row=0, column=5, padx=5) self.clear_button.grid(row=0, column=6, padx=5) self.button_frame.grid(row=0, column=0, columnspan=7, pady=8) self.canvas_experiment.grid(row=1, pady=5, padx=20, columnspan=7) self.image_save_button.grid(row=0, column=8, sticky=tk.N) self.setup_canvas()
def init_gui(self): """Builds GUI.""" global prefsfile message = [] fontsize = 11 # Read user preferences file, get default font size from it. prefspath = os.path.expanduser(prefsfile) if os.path.exists(prefspath): with open(prefspath, 'r') as f: self.prefs = json.load(f) if 'fontsize' in self.prefs: fontsize = self.prefs['fontsize'] else: self.prefs = {} s = ttk.Style() available_themes = s.theme_names() s.theme_use(available_themes[0]) s.configure('bg.TFrame', background='gray40') s.configure('italic.TLabel', font=('Helvetica', fontsize, 'italic')) s.configure('title.TLabel', font=('Helvetica', fontsize, 'bold italic'), foreground='brown', anchor='center') s.configure('normal.TLabel', font=('Helvetica', fontsize)) s.configure('red.TLabel', font=('Helvetica', fontsize), foreground='red') s.configure('green.TLabel', font=('Helvetica', fontsize), foreground='green3') s.configure('blue.TLabel', font=('Helvetica', fontsize), foreground='blue') s.configure('normal.TButton', font=('Helvetica', fontsize), border=3, relief='raised') s.configure('red.TButton', font=('Helvetica', fontsize), foreground='red', border=3, relief='raised') s.configure('green.TButton', font=('Helvetica', fontsize), foreground='green3', border=3, relief='raised') s.configure('blue.TButton', font=('Helvetica', fontsize), foreground='blue', border=3, relief='raised') s.configure('redtitle.TButton', font=('Helvetica', fontsize, 'bold italic'), foreground='red', border=3, relief='raised') s.configure('bluetitle.TButton', font=('Helvetica', fontsize, 'bold italic'), foreground='blue', border=3, relief='raised') # These values to be overridden from arguments self.rootpath = None self.project = None self.logfile = None self.msock = None self.help = None # Create the help window if os.path.exists(netgen_script_dir + '/netgen_help.txt'): self.help = HelpWindow(self, fontsize=fontsize) with io.StringIO() as buf, contextlib.redirect_stdout(buf): self.help.add_pages_from_file('lvs_help.txt') message = buf.getvalue() # Set the help display to the first page self.help.page(0) # Variables used by option menus and other stuff self.project = "(no selection)" self.layout = "(default)" self.schematic = "(default)" self.tech = "(none)" self.lvs_setup = '' self.lvsdata = {} # Root window title self.root.title('LVS Manager') self.root.option_add('*tearOff', 'FALSE') self.pack(side='top', fill='both', expand='true') pane = tkinter.PanedWindow(self, orient='vertical', sashrelief='groove', sashwidth=6) pane.pack(side='top', fill='both', expand='true') self.toppane = ttk.Frame(pane) self.botpane = ttk.Frame(pane) # Get username if 'username' in self.prefs: username = self.prefs['username'] else: username = os.environ['USER'] # Label with the user self.toppane.title_frame = ttk.Frame(self.toppane) self.toppane.title_frame.pack(side='top', fill='x') self.toppane.title_frame.title = ttk.Label(self.toppane.title_frame, text='User:'******'red.TLabel') self.toppane.title_frame.user = ttk.Label(self.toppane.title_frame, text=username, style='blue.TLabel') self.toppane.title_frame.title.grid(column=0, row=0, ipadx=5) self.toppane.title_frame.user.grid(column=1, row=0, ipadx=5) self.toppane.title2_frame = ttk.Frame(self.toppane) self.toppane.title2_frame.pack(side='top', fill='x') self.toppane.title2_frame.project_label = ttk.Label( self.toppane.title2_frame, text="Project:", style='title.TLabel') self.toppane.title2_frame.project_label.grid(column=0, row=0, ipadx=5) # New project select button self.toppane.title2_frame.project_select = ttk.Button( self.toppane.title2_frame, text=self.project, style='normal.TButton', command=self.choose_project) self.toppane.title2_frame.project_select.grid(column=1, row=0, ipadx=5) tooltip.ToolTip(self.toppane.title2_frame.project_select, text="Select new project") # Show path to project self.toppane.title2_frame.path_label = ttk.Label( self.toppane.title2_frame, text=self.project, style='normal.TLabel') self.toppane.title2_frame.path_label.grid(column=2, row=0, ipadx=5, padx=10) # Show top-level layout cellname with select button. Initial cell name is the top-level cell. self.toppane.title2_frame.tech_label = ttk.Label( self.toppane.title2_frame, text="Technology setup:", style='title.TLabel') self.toppane.title2_frame.tech_label.grid(column=3, row=0, ipadx=5) self.toppane.title2_frame.tech_select = ttk.Button( self.toppane.title2_frame, text=self.tech, style='normal.TButton', command=self.choose_tech) self.toppane.title2_frame.tech_select.grid(column=4, row=0, ipadx=3, padx=3) self.toppane.title2_frame.layout_label = ttk.Label( self.toppane.title2_frame, text="Layout:", style='title.TLabel') self.toppane.title2_frame.layout_label.grid(column=0, row=1, ipadx=5) self.toppane.title2_frame.layout_select = ttk.Button( self.toppane.title2_frame, text=self.layout, style='normal.TButton', command=self.choose_layout) self.toppane.title2_frame.layout_select.grid(column=1, row=1, ipadx=3, padx=3) # Show top-level schematic cellname with select button. Initial cell name is the top-level cell. self.toppane.title2_frame.schem_label = ttk.Label( self.toppane.title2_frame, text="Schematic:", style='title.TLabel') self.toppane.title2_frame.schem_label.grid(column=3, row=1, ipadx=5) self.toppane.title2_frame.schem_select = ttk.Button( self.toppane.title2_frame, text=self.schematic, style='normal.TButton', command=self.choose_netlist) self.toppane.title2_frame.schem_select.grid(column=4, row=1, ipadx=3, padx=3) tooltip.ToolTip(self.toppane.title2_frame.project_select, text="Select new project") tooltip.ToolTip(self.toppane.title2_frame.layout_select, text="Select a layout subcirucit to compare") tooltip.ToolTip(self.toppane.title2_frame.schem_select, text="Select a schematic subcirucit to compare") #--------------------------------------------- ttk.Separator(self.toppane, orient='horizontal').pack(side='top', fill='x') #--------------------------------------------- # Create listbox of Circuit1 vs. Circuit2 results height = 10 self.toppane.lvsreport = TreeViewSplit(self.toppane, fontsize=fontsize) self.toppane.lvsreport.populate( "Layout:", [], "Schematic:", [], [ ["Run", True, self.run_lvs], # ["Find", True, self.findrecord] ], height=height) self.toppane.lvsreport.set_title("Line") self.toppane.lvsreport.pack(side='top', fill='both', expand='true') tooltip.ToolTip(self.toppane.lvsreport.get_button(0), text="Run LVS") #--------------------------------------------- # ttk.Separator(self, orient='horizontal').grid(column=0, row=3, sticky='ew') #--------------------------------------------- # Add a text window below the project name to capture output. Redirect # print statements to it. self.botpane.console = ttk.Frame(self.botpane) self.botpane.console.pack(side='top', fill='both', expand='true') self.text_box = ConsoleText(self.botpane.console, wrap='word', height=4) self.text_box.pack(side='left', fill='both', expand='true') console_scrollbar = ttk.Scrollbar(self.botpane.console) console_scrollbar.pack(side='right', fill='y') # attach console to scrollbar self.text_box.config(yscrollcommand=console_scrollbar.set) console_scrollbar.config(command=self.text_box.yview) # Add button bar at the bottom of the window self.botpane.bbar = ttk.Frame(self.botpane) self.botpane.bbar.pack(side='top', fill='x') # Define the "quit" button and action self.botpane.bbar.quit_button = ttk.Button(self.botpane.bbar, text='Quit', command=self.on_quit, style='normal.TButton') self.botpane.bbar.quit_button.grid(column=0, row=0, padx=5) # Define help button if self.help: self.botpane.bbar.help_button = ttk.Button(self.botpane.bbar, text='Help', command=self.help.open, style='normal.TButton') self.botpane.bbar.help_button.grid(column=2, row=0, padx=5) tooltip.ToolTip(self.botpane.bbar.help_button, text="Show help window") # Add the panes once the internal geometry is known. pane.add(self.toppane) pane.add(self.botpane) pane.paneconfig(self.toppane, stretch='first') # Redirect stdout and stderr to the console as the last thing to do. . . # Otherwise errors in the GUI get sucked into the void. self.stdout = sys.stdout self.stderr = sys.stderr sys.stdout = ConsoleText.StdoutRedirector(self.text_box) sys.stderr = ConsoleText.StderrRedirector(self.text_box) if message: print(message)
def add_factual_panel(self, labelframe, label, description, canvas, button, image, index): logger.info("Factual Page - add_factual_panel") labelframe.rowconfigure(0, weight=1) #labelframe.grid_columnconfigure(0, weight=1) labelframe.grid(row=0, column=0, padx=60, pady=0) self.image_frame = tk.Frame(labelframe) self.image_frame.configure(background='deepskyblue4') self.new_window_image_button = ttk.Button( self.image_frame, text="Zoom Image", command=lambda: self.open_image_window(image), style='Green.TButton') self.new_window_image_button.tooltip = tooltip.ToolTip( self.new_window_image_button, "Open in new window") self.image_save_button = ttk.Button( self.image_frame, text="Save Board", command=lambda: self.save_image_window(canvas, label.cget("text")), style='Green.TButton') self.image_save_button.tooltip = tooltip.ToolTip( self.image_save_button, "Save your additions to the Image.\n(will appear in lesson notes)") self.labeltext = label.cget("text") self.desctext = description.cget("text") self.text_zoom_button = ttk.Button( self.image_frame, text="Zoom Text", command=lambda: self.show_text_window(self.labeltext, self.desctext ), style='Green.TButton') self.text_zoom_button.tooltip = tooltip.ToolTip( self.text_zoom_button, "View Text in larger size") self.text_zoom_button.grid(row=0, column=1, padx=10) self.new_window_image_button.grid(row=0, column=0, padx=10) self.image_save_button.grid(row=0, column=2, padx=10) self.forward_button = ttk.Button(labelframe, image=self.buttonnextimage, command=lambda: self.nextfact(index), style='Green.TButton') self.forward_button.tooltip = tooltip.ToolTip(self.forward_button, "Next") self.backward_button = ttk.Button( labelframe, image=self.buttonbackimage, command=lambda: self.move_previous_fact(index), style='Green.TButton') self.backward_button.tooltip = tooltip.ToolTip(self.backward_button, "Previous") if (index != 2): self.forward_button.grid(row=4, column=4, sticky=tk.S) label.grid(row=0, column=1, columnspan=2, sticky=tk.W) description.grid(row=1, column=1, columnspan=3, sticky=tk.W) self.image_frame.grid(row=2, column=1, columnspan=3, sticky=tk.NSEW) self.event_generate("<Configure>") canvas.grid(row=3, rowspan=3, column=1, columnspan=3, padx=150, pady=5, sticky=tk.NSEW) if (index != 0): self.backward_button.grid(row=4, column=0, sticky=tk.S) button.grid(row=5, column=0, padx=5, sticky=tk.EW)
def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) #self.config({'bg':'blue'}) logger.info("Inside Factual Page Initialize") self.parent = parent self.configure(background='deepskyblue4') s = ttk.Style(self) self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) factual_content_list = Data_Flow_Player.get_factual_content() factual_content_terms = factual_content_list[0] print(factual_content_terms) factual_content_descriptions = factual_content_list[1] print(factual_content_descriptions) factual_content_images = factual_content_list[2] self.pen_color = 'bisque2' self.buttonnextimage = tk.PhotoImage(file="../images/arrows_next.png") self.buttonbackimage = tk.PhotoImage(file="../images/arrows_back.png") self.labelframeone = ttk.Labelframe(self, text="Did you know?", relief=tk.RIDGE, style='Red.TLabelframe') self.labelframetwo = ttk.Labelframe(self, text="Did you know?", relief=tk.RIDGE, style='Red.TLabelframe') self.labelframethree = ttk.Labelframe(self, text="Did you know?", relief=tk.RIDGE, style='Red.TLabelframe') self.factual_term_label_one = ttk.Label(self.labelframeone, text=factual_content_terms[0], background='deepskyblue4', foreground='ivory2', font=("helvetica", 18, 'bold')) self.factual_term_label_two = ttk.Label(self.labelframetwo, text=factual_content_terms[1], background='deepskyblue4', foreground='ivory2', font=("helvetica", 18, 'bold')) self.factual_term_label_three = ttk.Label( self.labelframethree, text=factual_content_terms[2], background='deepskyblue4', foreground='ivory2', font=("helvetica", 18, 'bold')) self.factual_description_label_one = ttk.Label( self.labelframeone, text=factual_content_descriptions[0].strip(), background='deepskyblue4', foreground='white', font=("helvetica", 16, 'bold'), wraplength=600) self.factual_description_label_two = ttk.Label( self.labelframetwo, text=factual_content_descriptions[1], background='deepskyblue4', foreground='white', font=("helvetica", 16, 'bold'), wraplength=600) self.factual_description_label_three = ttk.Label( self.labelframethree, text=factual_content_descriptions[2], background='deepskyblue4', foreground='white', font=("helvetica", 16, 'bold'), wraplength=600) self.factual_image1 = factual_content_images[0] self.factual_image2 = factual_content_images[1] self.factual_image3 = factual_content_images[2] self.canvas_image1 = tk.Canvas(self.labelframeone, bg='deepskyblue4', borderwidth=0, highlightthickness=0, relief=tk.FLAT) self.popup_menu_1 = tk.Menu(self.canvas_image1, background='deepskyblue4', foreground='white') self.popup_menu_1.add_command(label="Dark", command=self.switch_to_dark) self.popup_menu_1.add_command(label="Light", command=self.switch_to_light) self.popup_menu_1.add_command(label="Text") self.canvas_image1.bind('<Button-3>', self.show_popup_menu1) self.canvas_image2 = tk.Canvas(self.labelframetwo, bg='deepskyblue4', borderwidth=0, highlightthickness=0, relief=tk.FLAT) self.popup_menu_2 = tk.Menu(self.canvas_image2, background='deepskyblue4', foreground='white') self.popup_menu_2.add_command(label="Dark", command=self.switch_to_dark) self.popup_menu_2.add_command(label="Light", command=self.switch_to_light) self.popup_menu_2.add_command(label="Text") self.canvas_image2.bind('<Button-3>', self.show_popup_menu2) self.canvas_image3 = tk.Canvas(self.labelframethree, bg='deepskyblue4', borderwidth=0, highlightthickness=0, relief=tk.FLAT) self.popup_menu_3 = tk.Menu(self.canvas_image3, background='deepskyblue4', foreground='white') self.popup_menu_3.add_command(label="Dark", command=self.switch_to_dark) self.popup_menu_3.add_command(label="Light", command=self.switch_to_light) self.popup_menu_3.add_command(label="Text") self.canvas_image3.bind('<Button-3>', self.show_popup_menu3) self.canvas_image1.bind( "<B1-Motion>", lambda event, c=self.canvas_image1: self.paint(event, c)) self.canvas_image1.bind('<ButtonRelease-1>', self.reset) self.canvas_image2.bind( "<B1-Motion>", lambda event, c=self.canvas_image2: self.paint(event, c)) self.canvas_image2.bind('<ButtonRelease-1>', self.reset) self.canvas_image3.bind( "<B1-Motion>", lambda event, c=self.canvas_image3: self.paint(event, c)) self.canvas_image3.bind('<ButtonRelease-1>', self.reset) device = "laptop" try: if self.factual_image1 != "" and self.factual_image1 is not None: self.image1 = Image.open(self.factual_image1) if self.factual_image2 != "" and self.factual_image2 is not None: self.image2 = Image.open(self.factual_image2) if self.factual_image3 != "" and self.factual_image3 is not None: self.image3 = Image.open(self.factual_image3) except (FileNotFoundError, IsADirectoryError): #messagebox.showerror("Error", "Factual Images Could not be retrieved \n e.g. "+self.factual_image1) print(self.factual_image1) print(self.factual_image2) print(self.factual_image3) logger.exception("Factual Images cannot be retrieved") self.bind("<Configure>", self.resize_c) self.buttonimage = tk.PhotoImage(file="../images/speaker.png") self.voicebutton1 = ttk.Button( self.labelframeone, image=self.buttonimage, command=lambda: self.playtextsound(factual_content_descriptions[0], 'f'), style='Green.TButton') self.voicebutton2 = ttk.Button( self.labelframetwo, image=self.buttonimage, command=lambda: self.playtextsound(factual_content_descriptions[1], 'm'), style='Green.TButton') self.voicebutton3 = ttk.Button( self.labelframethree, image=self.buttonimage, command=lambda: self.playtextsound(factual_content_descriptions[2], 'f'), style='Green.TButton') self.voicebutton1.tooltip = tooltip.ToolTip(self.voicebutton1, "Read Aloud") self.voicebutton2.tooltip = tooltip.ToolTip(self.voicebutton2, "Read Aloud") self.voicebutton3.tooltip = tooltip.ToolTip(self.voicebutton3, "Read Aloud") self.factual_index = 0 self.add_factual_panel(self.labelframeone, self.factual_term_label_one, self.factual_description_label_one, self.canvas_image1, self.voicebutton1, self.factual_image1, self.factual_index) self.old_x, self.old_y = None, None
def __init__(self, initdir=None): self.top = Tk() self.top.geometry('850x560+200+180') self.top.wm_title("SLA2.4") #Label(self.top, text='').pack() fm_title = Frame(self.top) self.label_title = Label(fm_title, text='Site Log Analyzer v2.4',\ font = ('Helvetica', 16, 'bold'), fg= my_color_blue_office) self.label_title.pack() fm_title.pack() self.top.iconbitmap(icon_path) fm_directory = Frame(self.top) self.entry_label = Label(fm_directory, text="Search in: ") self.cwd = StringVar(self.top) self.entry_dir = Entry(fm_directory, width=80, textvariable=self.cwd) self.entry_dir.bind('<Return>', self.enter_directory) self.button_dir = Button(fm_directory, text='List directory', \ command=self.choose_dir, activeforeground='white', activebackground='orange') self.button_dir.pack(side=RIGHT) self.entry_label.pack(side=LEFT) self.entry_dir.pack(side=LEFT) fm_directory.pack() fm_listbox = Frame(self.top) self.listbox_dirsby = Scrollbar(fm_listbox) self.listbox_dirsby.pack(side=RIGHT, fill=Y) self.listbox_dirsbx = Scrollbar(fm_listbox, orient=HORIZONTAL) self.listbox_dirsbx.pack(side=BOTTOM, fill=X) self.list_v = StringVar() #selectmode=EXTENDED,BROWSE,MULTIPLE,SINGLE #exportselection is used to enable "ctrl+c" to copy the content selected #in the listbox into the windows clipboard when =1 self.listbox_dirs = Listbox(fm_listbox, height=10, width=10, selectmode=EXTENDED,\ exportselection=1,listvariable=self.list_v) #2017.8.23 BUG: 滚动轴导致程序挂掉,原因可能是由于多线程子线程更新GUI界面 #产生内部错误导致 #2017.10.25,fixthis BUG, 要想thread-safe,使用python3,或者使用mttkinter模块! self.listbox_dirs.bind('<Double-1>', self.setDirAndGo) self.listbox_dirs.bind('<1>', lambda event: self.listbox_click(event)) self.listbox_dirs.bind('<ButtonRelease-1>', lambda event: self.listbox_click_release(event)) self.listbox_dirs.bind('<Return>', self.setDirAndGo) #self.listbox_dirs.bind('<Return>', self.start_thread_analyse) #self.listbox_dirs.bind('<3>', self.listbox_Rclick) self.listbox_dirs['yscrollcommand'] = self.listbox_dirsby.set self.listbox_dirsby.config(command=self.listbox_dirs.yview) self.listbox_dirs['xscrollcommand'] = self.listbox_dirsbx.set self.listbox_dirsbx.config(command=self.listbox_dirs.xview) self.listbox_dirs.pack(expand=YES, fill=BOTH) self.listbox_dirs.focus_set() fm_listbox.pack(expand=YES, fill=BOTH) fm_search = Frame(self.top) label_search = Label(fm_search, text="Search for: ") self.keyword = StringVar(self.top) self.keyword.set(PREDIFINED_KEYWORD) self.combo_search = Combobox(fm_search, width=30, textvariable=self.keyword) self.combo_search.bind('<KeyPress-Escape>', self.get_default_keywords) s = "keywords.csv is the predefined keywords data\nyou can input a specific keyword\nclick 'esc' for default" tooltip.ToolTip(self.combo_search, msg=None, msgFunc=lambda: s, follow=True, delay=0.2) #read the first 10 custom keywords in history file 'custom_keyword.txt' self.ck_list = [] self.ck_list = get_custom_keyword() if self.ck_list: value = self.ck_list[-10:] value.reverse() self.combo_search['values'] = value self.ck_list = [] else: self.ck_list = [] label_search.pack(side=LEFT) self.combo_search.pack(side=LEFT) #feature files type filtering Label(fm_search, text="in files of: ").pack(side=LEFT) self.v_files_types = StringVar() self.v_files_types.set('.*\.txt;.*\.out') self.entry_files_type = Entry(fm_search, width=30, textvariable=self.v_files_types) self.entry_files_type.pack(side=LEFT) self.entry_files_type.bind('<KeyPress-Escape>', self.get_default_files_filters) fs = "Refer to Python Regular Expression\n '.*'means any characters\n use ';' to seperate" tooltip.ToolTip(self.entry_files_type, msg=None, msgFunc=lambda: fs, follow=True, delay=0.2) #terminate button self.stop_b = Button(fm_search, text="Stop", command=self.terminate_threads) self.stop_b.pack(side=RIGHT) #search start button self.search_b = Button(fm_search, text="Auto analyse", command=self.start_thread_analyse, activeforeground\ ='white', activebackground='orange',bg = 'white', relief='raised', width=10) self.search_b.pack(side=RIGHT) fm_search.pack() tooltip.ToolTip( self.search_b, msg=None, msgFunc=\ lambda : 'To unpack, decode and search the selected files or directories', \ follow=True, delay=0.2) self.pro_fm = Frame(self.top) self.ptext = StringVar() self.ptext.set("") self.pro_label = Label(self.pro_fm, textvariable=self.ptext, justify='left') self.pro_label.grid(row=0, column=0) #.pack(side=LEFT) self.pro_fm.pack(side=LEFT) self.current_path_item_number = 0 self.current_path_item_selected_number = 0 ############# menu init ################################ menubar = Menu(self.top) #keyword update menu menubar.add_command(label='keywords', command=self.menu_keywords) #filter_menu self.search_filter = ['none'] filter_menu = Menu(menubar, tearoff=0) #all the module used for filter keyword belonging to that module out #['Telecom', 'Platform', 'OAM']) self.lf = list(set(zip(*PRE_KEYWORD_LIST)[1])) self.d_filter = {} for i in range(len(self.lf)): self.d_filter[self.lf[i]] = StringVar() #filter_menu filter_menu.add_command(label="select all", command=self.menu_selectall) filter_menu.add_separator() for item, v in self.d_filter.items(): #filter_menu.add_command(label = item,command=self.menu_hello) filter_menu.add_checkbutton(label = item,command=self.menu_filter,\ variable=v) #将menubar 的menu 属性指定为filemenu,即filemenu 为menubar 的下拉菜单 menubar.add_cascade(label='Filters', menu=filter_menu) #decode menue menubar.add_command(label='RTTP', command=self.menu_decode_log) #decode menue menubar.add_command(label='FTP', command=self.menu_start_monitor_ftp_download) #about menue about_menu = Menu(menubar, tearoff=0) about_menu.add_command(label='About', command=self.menu_about) about_menu.add_separator() about_menu.add_command(label='How To Use', command=self.menu_howto) menubar.add_cascade(label='About', menu=about_menu) self.top['menu'] = menubar ##popup menu self.popup_menu = Menu(self.top, tearoff=0) self.popup_menu.add_command(label='Open', command=self.cm_file_open) self.popup_menu.add_separator() self.popup_menu.add_command(label='Open folder', command=self.cm_folder_open) self.popup_menu.add_separator() self.popup_menu.add_command(label='Unpack', command=self.cm_start_unpack) self.popup_menu.add_separator() self.popup_menu.add_command(label='Search', command=self.cm_start_file_search) self.popup_menu.add_separator() self.popup_menu.add_command(label='Decode', command=self.cm_start_bsc_decode) self.popup_menu.add_separator() self.popup_menu.add_command(label='Lines Repetition', command=self.cm_start_logline_count) #popup_menu.entryconfig("Open", state="disable") ############# menu init ################################ #MAC OS GUI if (self.top.tk.call('tk', 'windowingsystem') == 'aqua'): self.listbox_dirs.bind( '<3>', lambda event: self.listbox_Rclick(event, self.popup_menu)) self.listbox_dirs.bind( '<Control-1>', lambda event: self.listbox_Rclick(event, self.popup_menu)) #Win32 else: #右击可以弹出菜单,用lambda的写法可以传递参数 self.listbox_dirs.bind( '<3>', lambda event: self.listbox_Rclick(event, self.popup_menu)) if initdir: #self.cwd.set(os.getcwd()) #desktop is default path self.cwd.set(DESKTOP_PATH) self.menu_selectall() self.enter_directory() self.dnd_enable(self.listbox_dirs)
def display(self, param=None, globcond=None, filename=None): # (Diagnostic) # print('failure report: passed parameter ' + str(param)) # Destroy existing contents. for widget in self.mainarea.faildisplay.winfo_children(): widget.destroy() if not param: param = self.data # 'param' is a dictionary pulled in from the annotate datasheet. # If the failure display was called, then 'param' should contain # record called 'results'. If the parameter has no results, then # there is nothing to do. if filename and 'plot' in param: simfiles = os.path.split( filename)[0] + '/ngspice/char/simulation_files/' self.failframe.grid_forget() self.plotframe.grid(row=0, column=0, sticky='nsew') # Clear the plotframe and remake for widget in self.plotframe.winfo_children(): widget.destroy() plotrec = param['plot'] results = param['results'] if 'variables' in param: variables = param['variables'] else: variables = [] canvas = cace_makeplot.makeplot(plotrec, results, variables, parent=self.plotframe) if 'display' in param: ttk.Label(self.plotframe, text=param['display'], style='title.TLabel').grid(row=1, column=0) canvas.show() canvas.get_tk_widget().grid(row=0, column=0, sticky='nsew') self.data = param # Display the button to return to the table view self.bbar.table_button.grid(column=1, row=0, padx=5) self.bbar.table_button.configure( command=lambda param=param, globcond=globcond, filename= filename: self.display(param, globcond, filename)) elif not 'results' in param: print("No results to build a report with.") return else: self.data = param self.plotframe.grid_forget() self.failframe.grid(column=0, row=0, sticky='nsew') faild = self.mainarea.faildisplay # definition for convenience results = param['results'] names = results[0] units = results[1] results = results[2:] # Check for transient simulation if 'TIME' in names: # Transient data are (usually) too numerous to tabulate, so go straight to plot self.table_to_plot('TIME', globcond, filename) return # Check for Monte Carlo simulation if 'ITERATIONS' in names: # Monte Carlo data are too numerous to tabulate, so go straight to plot self.table_to_histogram(globcond, filename) return # Numerically sort by result (to be done: sort according to up/down # criteria, which will be retained per header entry) results.sort(key=lambda row: float(row[0]), reverse=self.sortdir) # To get ranges, transpose the results matrix, then make unique ranges = list(map(list, zip(*results))) for r, vrange in enumerate(ranges): try: vmin = min(float(v) for v in vrange) vmax = max(float(v) for v in vrange) if vmin == vmax: ranges[r] = [str(vmin)] else: ranges[r] = [str(vmin), str(vmax)] except ValueError: ranges[r] = list(set(vrange)) pass faild.titlebar = ttk.Frame(faild) faild.titlebar.grid(row=0, column=0, sticky='ewns') faild.titlebar.label1 = ttk.Label(faild.titlebar, text='Electrical Parameter: ', style='italic.TLabel') faild.titlebar.label1.pack(side='left', padx=6, ipadx=3) if 'display' in param: faild.titlebar.label2 = ttk.Label(faild.titlebar, text=param['display'], style='normal.TLabel') faild.titlebar.label2.pack(side='left', padx=6, ipadx=3) faild.titlebar.label3 = ttk.Label(faild.titlebar, text=' Method: ', style='italic.TLabel') faild.titlebar.label3.pack(side='left', padx=6, ipadx=3) faild.titlebar.label4 = ttk.Label(faild.titlebar, text=param['method'], style='normal.TLabel') faild.titlebar.label4.pack(side='left', padx=6, ipadx=3) if 'min' in param: if 'target' in param['min']: faild.titlebar.label7 = ttk.Label(faild.titlebar, text=' Min Limit: ', style='italic.TLabel') faild.titlebar.label7.pack(side='left', padx=3, ipadx=3) faild.titlebar.label8 = ttk.Label( faild.titlebar, text=param['min']['target'], style='normal.TLabel') faild.titlebar.label8.pack(side='left', padx=6, ipadx=3) if 'unit' in param: faild.titlebar.label9 = ttk.Label( faild.titlebar, text=param['unit'], style='italic.TLabel') faild.titlebar.label9.pack(side='left', padx=3, ipadx=3) if 'max' in param: if 'target' in param['max']: faild.titlebar.label10 = ttk.Label(faild.titlebar, text=' Max Limit: ', style='italic.TLabel') faild.titlebar.label10.pack(side='left', padx=6, ipadx=3) faild.titlebar.label11 = ttk.Label( faild.titlebar, text=param['max']['target'], style='normal.TLabel') faild.titlebar.label11.pack(side='left', padx=6, ipadx=3) if 'unit' in param: faild.titlebar.label12 = ttk.Label( faild.titlebar, text=param['unit'], style='italic.TLabel') faild.titlebar.label12.pack(side='left', padx=3, ipadx=3) # Simplify view by removing constant values from the table and just listing them # on the second line. faild.constants = ttk.Frame(faild) faild.constants.grid(row=1, column=0, sticky='ewns') faild.constants.title = ttk.Label(faild.constants, text='Constant Conditions: ', style='italic.TLabel') faild.constants.title.grid(row=0, column=0, padx=6, ipadx=3) j = 0 for condname, unit, range in zip(names, units, ranges): if len(range) == 1: labtext = condname # unit = self.findunit(condname, param, globcond) labtext += ' = ' + range[0] + ' ' + unit + ' ' row = int(j / 3) col = 1 + (j % 3) ttk.Label(faild.constants, text=labtext, style='blue.TLabel').grid(row=row, column=col, padx=6, sticky='nsew') j += 1 body = ttk.Frame(faild, style='bg.TFrame') body.grid(row=2, column=0, sticky='ewns') # Print out names j = 0 for condname, unit, range in zip(names, units, ranges): # Now find the range for each entry from the global and local conditions. # Use local conditions if specified, otherwise default to global condition. # Each result is a list of three numbers for min, typ, and max. List # entries may be left unfilled. if len(range) == 1: continue labtext = condname plottext = condname if j == 0: # Add unicode arrow up/down depending on sort direction labtext += ' \u21e9' if self.sortdir else ' \u21e7' header = ttk.Button(body, text=labtext, style='title.TButton', command=self.changesort) tooltip.ToolTip(header, text='Reverse order of results') else: header = ttk.Button( body, text=labtext, style='title.TLabel', command=lambda plottext=plottext, globcond=globcond, filename=filename: self.table_to_plot( plottext, globcond, filename)) tooltip.ToolTip( header, text='Plot results with this condition on the X axis') header.grid(row=0, column=j, sticky='ewns') # Second row is the measurement unit # if j == 0: # # Measurement unit of result in first column # if 'unit' in param: # unit = param['unit'] # else: # unit = '' # No units # else: # # Measurement unit of condition in other columns # # Find condition in local conditions else global conditions # unit = self.findunit(condname, param, globcond) unitlabel = ttk.Label(body, text=unit, style='brown.TLabel') unitlabel.grid(row=1, column=j, sticky='ewns') # (Pick up limits when all entries have been processed---see below) j += 1 # Now list entries for each failure record. These should all be in the # same order. m = 2 for result in results: m += 1 j = 0 condition = result[0] lstyle = 'normal.TLabel' value = float(condition) if 'min' in param: minrec = param['min'] if 'calc' in minrec: calc = minrec['calc'] else: calc = 'min' if self.check_failure(minrec, calc, value): lstyle = 'red.TLabel' if 'max' in param: maxrec = param['max'] if 'calc' in maxrec: calc = maxrec['calc'] else: calc = 'max' if self.check_failure(maxrec, calc, value): lstyle = 'red.TLabel' for condition, range in zip(result, ranges): if len(range) > 1: pname = ttk.Label(body, text=condition, style=lstyle) pname.grid(row=m, column=j, sticky='ewns') j += 1 # Row 2 contains the ranges of each column j = 1 k = 1 for vrange in ranges[1:]: if len(vrange) > 1: condlimits = '( ' # This is a bit of a hack; results are assumed floating-point # unless they can't be resolved as a number. So numerical values # that should be treated as integers or strings must be handled # here according to the condition type. if names[k].split(':')[0] == 'DIGITAL': for l in vrange: condlimits += str(int(float(l))) + ' ' else: for l in vrange: condlimits += l + ' ' condlimits += ')' header = ttk.Label(body, text=condlimits, style='blue.TLabel') header.grid(row=2, column=j, sticky='ewns') j += 1 k += 1 # Add padding around widgets in the body of the failure report, so that # the frame background comes through, making a grid. for child in body.winfo_children(): child.grid_configure(ipadx=5, ipady=1, padx=2, pady=2) # Resize the window to fit in the display, if necessary. self.size_failreport() # Don't put the button at the bottom to return to table view. self.bbar.table_button.grid_forget() # Finally, open the window if it was not already open. self.open()
def __init__(self, parent=None, fontsize=11, *args, **kwargs): '''See the __init__ for Tkinter.Toplevel.''' tkinter.Toplevel.__init__(self, parent, *args, **kwargs) s = ttk.Style() s.configure('bg.TFrame', background='gray40') s.configure('italic.TLabel', font=('Helvetica', fontsize, 'italic'), anchor='west') s.configure('title.TLabel', font=('Helvetica', fontsize, 'bold italic'), foreground='brown', anchor='center') s.configure('normal.TLabel', font=('Helvetica', fontsize)) s.configure('red.TLabel', font=('Helvetica', fontsize), foreground='red') s.configure('green.TLabel', font=('Helvetica', fontsize), foreground='green4') s.configure('blue.TLabel', font=('Helvetica', fontsize), foreground='blue') s.configure('brown.TLabel', font=('Helvetica', fontsize, 'italic'), foreground='brown', anchor='center') s.configure('normal.TButton', font=('Helvetica', fontsize), border=3, relief='raised') s.configure('red.TButton', font=('Helvetica', fontsize), foreground='red', border=3, relief='raised') s.configure('green.TButton', font=('Helvetica', fontsize), foreground='green4', border=3, relief='raised') s.configure('title.TButton', font=('Helvetica', fontsize, 'bold italic'), foreground='brown', border=0, relief='groove') self.withdraw() self.title('Local Characterization Report') self.root = parent.root self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) # Scrolled frame: Need frame, then canvas and scrollbars; finally, the # actual grid of results gets placed in the canvas. self.failframe = ttk.Frame(self) self.failframe.grid(column=0, row=0, sticky='nsew') self.mainarea = tkinter.Canvas(self.failframe) self.mainarea.grid(row=0, column=0, sticky='nsew') self.mainarea.faildisplay = ttk.Frame(self.mainarea) self.mainarea.create_window((0, 0), window=self.mainarea.faildisplay, anchor="nw", tags="self.frame") # Create a frame for displaying plots, but don't put it in the grid. # Make it resizeable. self.plotframe = ttk.Frame(self) self.plotframe.rowconfigure(0, weight=1) self.plotframe.columnconfigure(0, weight=1) # Main window resizes, not the scrollbars self.failframe.rowconfigure(0, weight=1) self.failframe.columnconfigure(0, weight=1) # Add scrollbars xscrollbar = ttk.Scrollbar(self.failframe, orient='horizontal') xscrollbar.grid(row=1, column=0, sticky='nsew') yscrollbar = ttk.Scrollbar(self.failframe, orient='vertical') yscrollbar.grid(row=0, column=1, sticky='nsew') # Attach viewing area to scrollbars self.mainarea.config(xscrollcommand=xscrollbar.set) xscrollbar.config(command=self.mainarea.xview) self.mainarea.config(yscrollcommand=yscrollbar.set) yscrollbar.config(command=self.mainarea.yview) # Set up configure callback self.mainarea.faildisplay.bind("<Configure>", self.frame_configure) self.bbar = ttk.Frame(self) self.bbar.grid(column=0, row=1, sticky="news") self.bbar.close_button = ttk.Button(self.bbar, text='Close', command=self.close, style='normal.TButton') self.bbar.close_button.grid(column=0, row=0, padx=5) # Table button returns to table view but is only displayed for plots. self.bbar.table_button = ttk.Button(self.bbar, text='Table', style='normal.TButton') self.protocol("WM_DELETE_WINDOW", self.close) tooltip.ToolTip(self.bbar.close_button, text='Close detail view of conditions and results') self.sortdir = False self.data = []
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) logger.info("Player container initialized") s = ttk.Style(self) s.theme_use("clam") s.configure('Green.TButton', background='white', foreground='royalblue4', font=('helvetica', 12, 'bold'), bordercolor="royalblue4") s.map('Green.TButton', background=[('active', '!disabled', 'cyan'), ('pressed', 'white')], foreground=[('pressed', 'royalblue4'), ('active', 'royalblue4')]) s.configure('TScrollbar', background='royalblue4', foreground='deepskyblue4') s.map('TScrollbar', background=[('active', '!disabled', 'deepskyblue4'), ('pressed', 'snow')], foreground=[('pressed', 'royalblue4'), ('active', 'royalblue4')]) s.configure('Red.TLabelframe', background='deepskyblue4', bordercolor="royalblue4") s.configure('Red.TLabelframe.Label', font=('helvetica', 15, 'bold')) s.configure('Red.TLabelframe.Label', foreground='white') s.configure('Red.TLabelframe.Label', background='deepskyblue4') self.title("Learning Room") self.configure(background='deepskyblue4') self.headerimage = tk.PhotoImage(file="../images/learning.png") ttk.Label(self, text="Learning Room", image=self.headerimage, compound=tk.RIGHT, background='deepskyblue4', font=("helvetica", 18, 'bold'), foreground='white').pack(side=tk.TOP) self.tool_frame = tk.Frame(self, background="deepskyblue4") self.lbbutton_hide = ttk.Button(self.tool_frame, text="Leader Board", command=self.show_leaderboard, style='Green.TButton') self.timer_button = ttk.Button(self.tool_frame, text="Timer", command=self.launch_timer, style='Green.TButton') self.timer_button.tooltip = tooltip.ToolTip(self.timer_button, "Launch Timer App") self.tool_frame.pack(side=tk.TOP, anchor=tk.NE, pady=5, padx=5) self.lbbutton_hide.pack(side=tk.RIGHT, anchor=tk.NE, pady=5, padx=5) self.timer_button.pack(side=tk.RIGHT, anchor=tk.NE, pady=5, padx=5) self.show_hide_flag = 1 app = lesson_list_player.MagicLessonList(parent=self) app.geometry("350x600+50+50") self.wait_window(app) if hasattr(self, "selected_lessons") is False: self.destroy() print(self.selected_lessons) Data_Flow_Player.TEST_ROW = self.selected_lessons[0] Data_Flow_Player.imageroot = Data_Flow_Player.file_root + os.path.sep + "Lessons" + os.path.sep + "Lesson" + str( Data_Flow_Player.TEST_ROW) + os.path.sep + "images" + os.path.sep Data_Flow_Player.videoroot = Data_Flow_Player.file_root + os.path.sep + "Lessons" + os.path.sep + "Lesson" + str( Data_Flow_Player.TEST_ROW) + os.path.sep + "videos" + os.path.sep Data_Flow_Player.saved_canvas = Data_Flow_Player.file_root + os.path.sep + "Lessons" + os.path.sep + "Lesson" + str( Data_Flow_Player.TEST_ROW) + os.path.sep + "saved_boards" self.page_index = 0 self.resizable(width=True, height=True) s = ttk.Style() s.theme_use('clam') #[('pressed' ,'dark olive green'),('active','white')],foreground=[('pressed','PeachPuff2'),('active', 'PeachPuff2')]) self.screen_width = self.winfo_screenwidth() self.screen_height = self.winfo_screenheight() self.bframe = tk.Frame(self, background="deepskyblue4", width=100, height=50) self.nextimage = tk.PhotoImage(file="../images/next.png") self.nextbutton = ttk.Button( self.bframe, text="Next Step", image=self.nextimage, command=lambda: self.show_next_page(self.page_index), style='Green.TButton') self.backimage = tk.PhotoImage(file="../images/back.png") self.backbutton = ttk.Button( self.bframe, text="Last Step", image=self.backimage, command=lambda: self.show_previous_page(self.page_index), style='Green.TButton') self.nextbutton.tooltip = tooltip.ToolTip(self.nextbutton, "Move Next") self.backbutton.tooltip = tooltip.ToolTip(self.backbutton, "Move Back") self.nextbutton.pack(side=tk.RIGHT, anchor=tk.NE) self.backbutton.pack(side=tk.TOP, anchor=tk.NE, padx=10) self.show_title_page()
def __init__(self, parent_top): global HOST global PORT global ACC global PWD global DOWNLOAD_DIR global EXSERVER global MAIL_ADD global AD4_ACC global AD4_PWD global PROGRESS_THREADS self.parent_top = parent_top self.ftp_top = Toplevel(parent_top) self.ftp_top.title("Mail Monitor") self.ftp_top.geometry('600x330+300+220') self.ftp_top.iconbitmap(DOWNLOADER_ICON) #self.ftp_top.attributes("-toolwindow", 1) #self.ftp_top.wm_attributes('-topmost',1) self.ftp_top.protocol("WM_DELETE_WINDOW", lambda: self.ask_quit(self.ftp_top)) self.running = True #Label(self.ftp_top, text='').pack() #Label(self.ftp_top, text='').pack() fm0 = Frame(self.ftp_top) #Label(fm0, text='Mail Monitor v2.0',\ # font = ('Helvetica', 12, 'bold')).pack()#, fg= my_color_blue_office) Label(fm0, text='').pack() fm0.pack() self.dir_fm = Frame(self.ftp_top) self.v_saved_number = 0 self.l_savein = Label(self.dir_fm, text="Save in: ") self.v_savein = StringVar() self.entry_savein = Entry(self.dir_fm, width=66, textvariable=self.v_savein) self.v_savein.set(SAVE_DIR) #self.entry_savein.config(state='disabled') self.b_savein = Button(self.dir_fm, text='Choose directory', command=self.choose_dir, activeforeground\ ='white', activebackground='orange') self.b_savein.pack(side=RIGHT) self.l_savein.pack(side=LEFT) self.entry_savein.pack(side=LEFT) self.dir_fm.pack() self.pwindow_qconn = ttk.Panedwindow(self.ftp_top, orient=VERTICAL) self.lframe_direct = ttk.Labelframe(self.ftp_top, text='Direct Download',\ width= 620, height = 220) self.lframe_monitor = ttk.Labelframe(self.ftp_top, text='Auto Download',\ width= 620, height = 220) self.pwindow_qconn.add(self.lframe_direct) self.pwindow_qconn.add(self.lframe_monitor) #Host label and entry self.label_host = Label(self.lframe_direct, text='Ftp Host:').grid(row=0, column=0) self.v_host = StringVar() self.entry_host = Entry(self.lframe_direct, textvariable=self.v_host, width=50) self.entry_host.grid(row=0, column=1) ts1 = "Either input an ip:port address or a full ftp url:\n ftp://QD-BSC2:qdBSC#[email protected]:8080/" ts2 = "01_Training/02_PMU/02_Documents\n then click 'Direct download' to download files in this directory" ts = ts1 + ts2 tooltip.ToolTip(self.entry_host, msg=None, msgFunc=lambda: ts, follow=True, delay=0.2) #Port label and entry self.label_port = Label(self.lframe_direct, text='Port:') #self.label_port.grid(row=0,column=2) self.v_port = StringVar() self.entry_port = Entry(self.lframe_direct, textvariabl=self.v_port, width=20) #self.entry_port.grid(row=0,column=3) #Usrnamer label and entry self.label_user = Label(self.lframe_direct, text='Username:'******'Password:'******'Dirname:').grid(row=1, column=0) self.v_ddirname = StringVar() self.entry_ddirname = Entry(self.lframe_direct, textvariabl=self.v_ddirname, width=50) self.entry_ddirname.grid(row=1, column=1) #Download button self.button_direct = Button(self.lframe_direct,text="Direct dowload",\ width=20, command=self.start_direct_download, activeforeground='white', \ activebackground='orange',bg = 'white', relief='raised') self.button_direct.grid(row=2, column=3) #############Auto download############### self.fm_up = Frame(self.lframe_monitor) s1 = "Monitor 'Inbox' to automatically download files" s2 = " " s3 = "based on ftp information in mail with specified title" s = s1 + s2 + s3 self.v_chk = BooleanVar() self.chk_auto = Checkbutton(self.fm_up, text = s, variable = self.v_chk,\ command = self.periodical_check) self.chk_auto.pack() self.fm_up.pack() self.fm_config = Frame(self.lframe_monitor, height=50) #exchange serveHost label and entry self.label_exserver = Label(self.fm_config, text='Exchange Server:') self.label_exserver.grid(row=0, column=0) self.v_exserver = StringVar() self.entry_exserver = Entry(self.fm_config, textvariable=self.v_exserver, width=27) self.entry_exserver.grid(row=0, column=1) #Mail Address label and entry self.label_mail_add = Label(self.fm_config, text=' Mail Address:') self.label_mail_add.grid(row=0, column=2) self.v_mail_k_add = StringVar() self.entry_mail_add = Entry(self.fm_config, textvariabl=self.v_mail_k_add, width=29) self.entry_mail_add.grid(row=0, column=3) #Domain//Usrnamer label and entry self.label_csl = Label(self.fm_config, text='Domain\CSL:', justify=LEFT) self.label_csl.grid(row=1, column=0) self.v_csl = StringVar() self.entry_csl = Entry(self.fm_config, textvariabl=self.v_csl, width=27) self.entry_csl.grid(row=1, column=1) #CIP Password label and entry self.label_cip = Label(self.fm_config, text=' AD4 Password:'******'Mail Title Keyword:') self.label_mail_k.grid(row=2, column=0) self.v_mail_k = StringVar() self.entry_mail_k = Entry(self.fm_config, textvariable=self.v_mail_k, width=27) self.entry_mail_k.grid(row=2, column=1) tts = "Refer to the Python regular expression\n '.*' means no filter or just leave it a blank" tooltip.ToolTip(self.entry_mail_k, msg=None, msgFunc=lambda: tts, follow=True, delay=0.2) self.label_interval = Label(self.fm_config, text='Monitor Interval(sec):') self.label_interval.grid(row=2, column=2) self.v_interval = StringVar() self.spin_interval = Spinbox(self.fm_config, textvariable=self.v_interval,\ width = 8, from_=1, to=8640,increment=1) self.spin_interval.grid(row=2, column=3) self.fm_config.pack() self.fm_mid = Frame(self.lframe_monitor, height=50) #button trigger monitor mails' titles self.ftp_queue = [] #like self.ftp_queue = [['ftp_info1','ftp_info2'],['ftp_info3'],['ftp_info4,ftp_info5']] self.v_ftp_number = StringVar() self.v_ftp_number.set(str(len(self.ftp_queue))) self.label_ftp_q = Label(self.fm_mid, textvariable=self.v_ftp_number) self.label_ftp_q.pack(side=RIGHT) Label(self.fm_mid, text="FTP Queued: ").pack(side=RIGHT) self.button_monitor = Button(self.fm_mid, text="Start monitor",\ command=self.start_monitor_download, activeforeground\ ='white', activebackground='orange',bg = 'white', relief='raised', width=20) self.button_monitor.pack() #grid(row=1,column=3) self.fm_mid.pack() #for read exchanger configuration self.pwindow_qconn.pack() Label(self.ftp_top, text=' ').pack() self.fm_tip = Frame(self.ftp_top) fm_label = Frame(self.fm_tip) #self.label_blank11 = Label(self.fm_tip,text= ' '*3).pack(side=LEFT) self.v_tip = StringVar() self.label_tip = Label(fm_label, textvariable=self.v_tip, justify=LEFT) self.label_tip.grid(row=0, column=0) fm_label.pack() fm_b = Frame(self.fm_tip) self.p = ttk.Progressbar(fm_b, orient=HORIZONTAL, mode='determinate', length=100, maximum=100) self.p.pack(side=LEFT) global PROGRESS_BAR global PROGRESS_STRVAR global PROGRESS_LBL self.v_p = StringVar() self.v_p.set("") PROGRESS_STRVAR = self.v_p self.p_label = Label(fm_b, textvariable=self.v_p) self.p_label.pack(side=LEFT) PROGRESS_LBL = self.p_label PROGRESS_BAR = self.p fm_b.pack(side=LEFT) self.fm_tip.pack(side=LEFT) PROGRESS_BAR.pack_forget() PROGRESS_LBL.pack_forget() #GUI finish #######retrive data from disk#############: data_bak = retrive_bak() if data_bak: self.v_host.set(data_bak.ftp_bak.host) self.v_port.set(data_bak.ftp_bak.port) self.v_user.set(data_bak.ftp_bak.user) self.v_pwd.set(data_bak.ftp_bak.pwd) self.v_ddirname.set(data_bak.ftp_bak.target_dir) self.v_mail_k.set(data_bak.ftp_bak.mail_keyword) self.v_interval.set(data_bak.ftp_bak.interval) self.v_exserver.set(data_bak.ol_bak.server) self.v_mail_k_add.set(data_bak.ol_bak.mail) self.v_mail_k_add.set(data_bak.ol_bak.mail) self.v_csl.set(data_bak.ol_bak.user) self.v_cip.set(data_bak.ol_bak.pwd) else: self.v_host.set(HOST) self.v_port.set(PORT) self.v_user.set(ACC) self.v_pwd.set(PWD) self.v_ddirname.set(DOWNLOAD_DIR) self.v_mail_k.set(MAIL_KEYWORD) self.v_interval.set(MONITOR_INTERVAL) self.v_exserver.set(EXSERVER) self.v_mail_k_add.set(MAIL_ADD) self.v_csl.set(AD4_ACC) self.v_cip.set(AD4_PWD) #######retrive data from disk#############: self.periodical_check() #start a ever running progress tip thread t_progress_tip = threading.Thread(target=self.start_progress_tip) t_progress_tip.start() PROGRESS_THREADS.append(t_progress_tip) print("DEBUG my_ftp.py progress thread start", t_progress_tip)
def __init__(self, initdir=None): self.top = Tk() self.top.geometry('560x520+200+180') self.top.wm_title("VC2.0") Label(self.top, text='').pack() fm_title = Frame(self.top) self.label_title = Label(fm_title, text='Version Compare v2.0',\ font = ('Helvetica', 16, 'bold'), fg =MY_COLOR_BLUE_OFFICE) self.label_title.pack() fm_title.pack() self.top.iconbitmap('vc.ico') fm_listbox = Frame(self.top) ############################## fm_listbox_base = Frame(fm_listbox) ''' self.listbox_baseby = Scrollbar(fm_listbox_base) self.listbox_baseby.pack(side=RIGHT, fill=Y) self.listbox_basebx = Scrollbar(fm_listbox_base,orient=HORIZONTAL) self.listbox_basebx.pack(side=BOTTOM, fill=X) ''' self.list_base_v = StringVar() #selectmode=EXTENDED,BROWSE,MULTIPLE,SINGLE #exportselection is used to enable "ctrl+c" to copy the content selected #in the listbox into the windows clipboard when =1 self.listbox_base = Listbox(fm_listbox_base, height=20, width=34, selectmode=BROWSE,\ exportselection=1,listvariable=self.list_base_v) s = "Drag & Drop folders that you want to count lines and make diffs" tooltip.ToolTip(self.listbox_base, msg=None, msgFunc=lambda : s, follow=True, delay=0.2) ''' self.listbox_base['yscrollcommand'] = self.listbox_baseby.set self.listbox_baseby.config(command=self.listbox_base.yview) self.listbox_base['xscrollcommand'] = self.listbox_basebx.set self.listbox_basebx.config(command=self.listbox_base.xview) ''' Label(fm_listbox_base, text = 'BASE').pack() self.listbox_base.pack() self.base_file_list = [] self.ptext_base = StringVar() self.ptext_base.set("") self.label_info_base = Label(fm_listbox_base, textvariable=self.ptext_base,justify='left') self.label_info_base.pack() fm_listbox_base.grid(row=0,column=0) ############################ label_compare = Label(fm_listbox, text="diff").grid(row=0,column=1) ############################ fm_listbox_latest = Frame(fm_listbox) self.list_latest_v = StringVar() self.listbox_latest = Listbox(fm_listbox_latest, height=20, width=34, selectmode=BROWSE,\ exportselection=1,listvariable=self.list_latest_v) Label(fm_listbox_latest, text='LATEST').pack() self.listbox_latest.pack() self.latest_file_list = [] self.ptext_latest = StringVar() self.ptext_latest.set("") self.label_info_latest = Label(fm_listbox_latest, textvariable=self.ptext_latest,justify='left') self.label_info_latest.pack() fm_listbox_latest.grid(row=0,column=2) ############################ fm_listbox.pack() fm_compare = Frame(self.top) self.button_compare = Button(fm_compare, text="Compare", command=self.compare_files,\ height=2,width=12) self.button_compare.pack() fm_compare.pack() self.dnd_enable(self.listbox_base, self.ptext_base, self.base_file_list) self.dnd_enable(self.listbox_latest, self.ptext_latest, self.latest_file_list)
def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) #self.config({'bg':'blue'}) logger.info("Inside MagicExperimentPage Initialize") self.configure(background='deepskyblue4') self.parent = parent s = ttk.Style(self) s.configure('Horizontal.Green.TScale', background='deepskyblue4', foreground='white') self.move_animation_Steps = 12 self.move_flag = False self.rowconfigure(0, weight=1) self.columnconfigure(0, weight=1) self.bind("<Configure>", self.resize_c) self.image_list = [] self.image_canvas_list = [] self.experiment_content_list = Data_Flow_Player.get_experiment_content( ) self.experiment_content_terms = self.experiment_content_list[0] self.image_map = {} self.experiment_content_images = self.experiment_content_list[1] self.labelframeone = ttk.Labelframe(self, text="Let us do this !", relief=tk.RIDGE, style='Red.TLabelframe') self.labelframeone.grid_rowconfigure(1, weight=1) self.labelframetwo = ttk.Labelframe( self, text="Step by Step we can change the world !", relief=tk.RIDGE, style='Red.TLabelframe') # self.canvas_experiment = tk.Canvas(self.labelframeone,bg="white",width=parent.winfo_width()/1.5,height=parent.winfo_height()/1.5) self.canvas_experiment = tk.Canvas(self.labelframeone, bg="white") self.popup_menu = tk.Menu(self.canvas_experiment, background='deepskyblue4', foreground='white') self.popup_menu.add_command(label="Text") self.popup_menu.add_command(label="Move Down") self.popup_menu.add_command(label="Move Right") self.popup_menu.add_command(label="Zoom") self.canvas_experiment.bind('<Button-3>', self.show_popup_menu) self.labelframeone.grid(row=0, column=0, pady=5, padx=20) self.labelframetwo.grid(row=0, column=1, pady=10, padx=20, sticky=tk.N) self.sound_flag = True self.fill_steps_frame(parent.screen_width, parent.screen_height) self.fill_canvas_frame(parent.screen_width, parent.screen_height) link_ext = Data_Flow_Player.get_link() if (link_ext is not None and link_ext != ""): self.link_button = ttk.Button( self.labelframetwo, text="Launch Link", command=lambda: self.launch_link(link_ext), style="Green.TButton") self.link_button.tooltip = tooltip.ToolTip(self.link_button, "Opens Browser") self.link_button.grid(row=10, column=2, sticky=tk.SW, padx=10)
def title_intro(self): logger.info("Player Title page title_intro") self.title_text = Data_Flow_Player.get_Title() self.topic_label = ttk.Label( self.labelframeone, text=self.title_text, font=('helvetica', 16, 'bold'), foreground='white', background='deepskyblue4', wraplength=self.parent_window.screen_width / 2.5) self.topic_label.pack(pady=10, anchor=tk.CENTER) title_image = Data_Flow_Player.get_title_image() self.image_frame = tk.Frame(self.labelframeone) self.image_frame.configure(background='deepskyblue4') self.new_window_image_button = ttk.Button( self.image_frame, text="Zoom Image", command=lambda: self.open_image_window(title_image), style='Green.TButton') self.new_window_image_button.tooltip = tooltip.ToolTip( self.new_window_image_button, "Open in new window") self.image_save_button = ttk.Button(self.image_frame, text="Save Board", style='Green.TButton') self.image_save_button.tooltip = tooltip.ToolTip( self.image_save_button, "Save your additions to the Image.\n(will appear in lesson notes)") self.show_video_button = ttk.Button(self.image_frame, text="Show Video", command=self.new_window, style='Green.TButton') self.show_video_button.tooltip = tooltip.ToolTip( self.show_video_button, "Launches VLC video player") self.new_window_image_button.pack(pady=5, side=tk.LEFT) self.image_save_button.pack(padx=5, side=tk.LEFT) self.show_video_button.pack(pady=5, side=tk.LEFT) self.image_frame.pack(anchor=tk.CENTER) self.canvas = tk.Canvas(self.labelframeone, background='deepskyblue4', borderwidth=0, highlightthickness=0, relief=tk.FLAT) self.popup_menu = Menu(self.canvas, background='deepskyblue4', foreground='white') self.popup_menu.add_command(label="Dark", command=self.switch_to_dark) self.popup_menu.add_command(label="Light", command=self.switch_to_light) self.popup_menu.add_command(label="Text") self.canvas.pack(padx=20, pady=10) self.canvas.bind('<Button-3>', self.show_popup_menu) self.image_save_button.configure(command=self.save_image_window) self.canvas.bind("<B1-Motion>", self.paint) self.canvas.bind('<ButtonRelease-1>', self.reset) self.bind("<Configure>", self.resize) self.notes_display() self.labelframeone.pack(padx=10) try: self.img = Image.open(title_image) except (FileNotFoundError, IsADirectoryError): # messagebox.showerror("Error", "Title image not found in the path \n" + title_image) logger.exception("TItle image cannot be loaded")
def start_flashcards(self): self.text_index = 0 self.reveal_index = 0 self.text_fact_index = 0 self.labelframetwo = ttk.Labelframe(self, text="Flash Cards", borderwidth=2, relief=tk.RIDGE, style="Red.TLabelframe") self.twocontrolframe = tk.Frame(self.labelframetwo, background="deepskyblue4") self.next_button = ttk.Button( self.twocontrolframe, text="Next Card", command=lambda: self.next_flashcard(self.text_index), style='Blue.TButton') self.next_button.tooltip = tooltip.ToolTip(self.next_button, "Next Card\nctrl-n") self.reveal_button = ttk.Button(self.twocontrolframe, text="Reveal Card", command=self.answer_flashcard, style='Blue.TButton') self.reveal_button.tooltip = tooltip.ToolTip(self.reveal_button, "Reveal Answer\nctrl-r") self.reveal_button.configure(state="disabled") self.show_leaderboard = ttk.Button(self.twocontrolframe, text="Show Leaderboard", command=self.show_board, style='Blue.TButton') self.show_leaderboard.tooltip = tooltip.ToolTip( self.show_leaderboard, "Show Leaderboard\nctrl-l") self.buttonimage = tk.PhotoImage(file="../images/speaker.png") term_text_list = data_capture_flashcard.get_Fact_Terms( self.lesson_list) description_text_list = data_capture_flashcard.get_Fact_Descriptions( self.lesson_list) image_list = data_capture_flashcard.get_Images(self.lesson_list) self.all_terms = FlashUtils.expandList(term_text_list) self.all_descriptions = FlashUtils.expandList(description_text_list) self.all_images = FlashUtils.expandImageList(image_list) self.bind( '<Control-Key-n>', lambda event, a=self.text_index: self.next_flashcard(a, event)) self.bind('<Control-Key-r>', self.answer_flashcard) self.bind('<Control-Key-l>', self.show_board) self.twocontrolframe.grid(row=0, column=0, sticky=tk.W, pady=5) self.next_button.grid(row=0, column=4, sticky=tk.W, padx=5) self.reveal_button.grid(row=0, column=2, sticky=tk.W, padx=5) self.show_leaderboard.grid(row=0, column=1, padx=10) self.term_text = tk.Text( self.labelframetwo, borderwidth=2, highlightthickness=0, relief=tk.RAISED, highlightcolor="royalblue4", wrap=tk.WORD, width=int(self.winfo_width() / 60), height=int(self.winfo_height() / 500), font=("helvetica", 18), foreground="royalblue4", background='white', ) self.answer_text = tk.Text( self.labelframetwo, borderwidth=2, highlightthickness=0, relief=tk.RAISED, highlightcolor="royalblue4", wrap=tk.WORD, width=int(self.winfo_width() / 60), height=int(self.winfo_height() / 70), font=("helvetica", 18), foreground="royalblue4", background='white', ) self.labelframetwo.grid(row=1, column=0, padx=200, pady=100, sticky=tk.NSEW) self.next_flashcard(self.text_index) self.answer_flashcard() self.answer_text.delete(1.0, tk.END)