def __init__(self, parent, name): tk.Toplevel.__init__(self, parent) self.parent=parent self.withdraw() self.name=name self.title('Eye Diagram: '+name) self.img = tk.PhotoImage(file=SignalIntegrity.App.IconsBaseDir+'AppIcon2.gif') self.tk.call('wm', 'iconphoto', self._w, self.img) self.protocol("WM_DELETE_WINDOW", self.onClosing) self.tabControl=ttk.Notebook(self) self.tab1=ttk.Frame(self.tabControl) self.tabControl.add(self.tab1,text='Vertical/Horizontal') self.tabControl.pack(expand=1,fill=tk.BOTH) self.eyeStatus=StatusBar(self.tab1) self.eyeStatus.pack(side=tk.TOP,fill=tk.X,expand=tk.NO) self.ParametersFrame=tk.Frame(self.tab1,relief=tk.RIDGE,borderwidth=5) self.ParametersFrame.pack(side=tk.LEFT,fill=tk.X,expand=tk.NO,anchor=tk.NW) self.tab2=ttk.Frame(self.tabControl) self.tabControl.add(self.tab2,text='Error Rates') self.BERFrame=tk.Frame(self.tab2,relief=tk.RIDGE,borderwidth=5) self.BERFrame.pack(side=tk.LEFT,fill=tk.X,expand=tk.NO,anchor=tk.NW) if SignalIntegrity.App.Preferences['Features.OpticalMeasurements']: self.tab3=ttk.Frame(self.tabControl) self.tabControl.add(self.tab3,text='Penalties') self.PenaltiesFrame=tk.Frame(self.tab3,relief=tk.RIDGE,borderwidth=5) self.PenaltiesFrame.pack(side=tk.LEFT,fill=tk.X,expand=tk.NO,anchor=tk.NW) self.bind('<FocusIn>',self.onFocus) self.resizable(False, False) self.deiconify() self.lift()
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) # Menu Bar # File Menu menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Tk.Menu(menubar) fileMenu.add_command(label="Open", underline=0, command=self.OnOpen) fileMenu.add_command(label="Exit", underline=1, command=_quit) menubar.add_cascade(label="File", menu=fileMenu) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH,expand=1) self.videopanel.pack(fill=Tk.BOTH,expand=1) ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay)
def __init__(self, win): ttk.Frame.__init__(self, win) frame_left = ttk.Frame(self) frame_right1 = ttk.Frame(self) frame_right2 = ttk.Frame(self) win.title("车牌识别") win.state("zoomed") self.pack(fill=tk.BOTH, expand=tk.YES, padx="10", pady="10") frame_left.pack(side=LEFT, expand=1, fill=BOTH) frame_right1.pack(side=TOP, expand=1, fill=tk.Y) frame_right2.pack(side=RIGHT, expand=0) ttk.Label(frame_left, text='原图:').pack(anchor="nw") ttk.Label(frame_right1, text='形状定位车牌位置:').grid(column=0, row=0, sticky=tk.W) from_pic_ctl = ttk.Button(frame_right2, text="来自图片", width=20, command=self.from_pic) from_vedio_ctl = ttk.Button(frame_right2, text="来自摄像头", width=20, command=self.from_vedio) from_img_pre = ttk.Button(frame_right2, text="查看形状预处理图像", width=20, command=self.show_img_pre) self.image_ctl = ttk.Label(frame_left) self.image_ctl.pack(anchor="nw") self.roi_ctl = ttk.Label(frame_right1) self.roi_ctl.grid(column=0, row=1, sticky=tk.W) ttk.Label(frame_right1, text='形状定位识别结果:').grid(column=0, row=2, sticky=tk.W) self.r_ctl = ttk.Label(frame_right1, text="", font=('Times', '20')) self.r_ctl.grid(column=0, row=3, sticky=tk.W) self.color_ctl = ttk.Label(frame_right1, text="", width="20") self.color_ctl.grid(column=0, row=4, sticky=tk.W) from_vedio_ctl.pack(anchor="se", pady="5") from_pic_ctl.pack(anchor="se", pady="5") from_img_pre.pack(anchor="se", pady="5") ttk.Label(frame_right1, text='颜色定位车牌位置:').grid(column=0, row=5, sticky=tk.W) self.roi_ct2 = ttk.Label(frame_right1) self.roi_ct2.grid(column=0, row=6, sticky=tk.W) ttk.Label(frame_right1, text='颜色定位识别结果:').grid(column=0, row=7, sticky=tk.W) self.r_ct2 = ttk.Label(frame_right1, text="", font=('Times', '20')) self.r_ct2.grid(column=0, row=8, sticky=tk.W) self.color_ct2 = ttk.Label(frame_right1, text="", width="20") self.color_ct2.grid(column=0, row=9, sticky=tk.W) self.predictor = predict.CardPredictor() self.predictor.train_svm()
def SetUp(self): self.TimeSeriesList = utils.sort_series( list(self.Model.EquationSolver.TimeSeries.keys())) self.SeriesBoxValue = StringVar() content = ttk.Frame(self) frame = ttk.Frame(content, borderwidth=5, relief='sunken') self.BoxWidget = ttk.Combobox(content, textvariable=self.SeriesBoxValue) self.BoxWidget.state([ 'readonly', ]) self.BoxWidget['values'] = self.TimeSeriesList # self.SeriesBoxValue.trace('w', self.ComboChange()) self.BoxWidget.bind('<<ComboboxSelected>>', self.ComboChange) self.BoxWidget.current(0) button = tk.Button(content, text='Next', command=self.OnButtonClick) button2 = tk.Button(content, text='Quit', command=self.quit) self.Equation = tk.Entry(content, state=['readonly'], textvariable=self.EquationString) self.EntryDescription = tk.Entry(content, state=[ 'readonly', ], textvariable=self.DescriptionString) self.CanvasFigure = matplotlib.pyplot.figure(1) Fig = matplotlib.figure.Figure(figsize=(7.5, 5), dpi=90) subplot = Fig.add_subplot(111) x = [] y = [] self.Line, = subplot.plot(x, y, 'bo-') self.Canvas = FigureCanvasTkAgg(Fig, master=content) self.OnButtonClick() content.grid(column=0, row=0) frame.grid(column=0, row=0, columnspan=7, rowspan=3) self.BoxWidget.grid(row=0, column=0, columnspan=2) button.grid(column=5, row=0) button2.grid(column=6, row=0) self.EntryDescription.grid(row=0, column=2, columnspan=3, sticky=['w', 'e']) self.Equation.grid(row=1, column=0, columnspan=7, sticky=['w', 'e']) self.Canvas.get_tk_widget().grid(column=0, row=2, columnspan=7, sticky=['n', 's', 'e', 'w']) content.columnconfigure(2, weight=1) content.columnconfigure(3, weight=1) content.columnconfigure(4, weight=1) content.rowconfigure(2, weight=1) self.Canvas.show() self.resizable(width=True, height=True) self.update()
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Tk.Menu(menubar) fileMenu.add_command(label="Open", underline=0, command=self.OnOpen) fileMenu.add_command(label="Exit", underline=1, command=_quit) menubar.add_cascade(label="File", menu=fileMenu) self.media_list_player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) next = ttk.Button(ctrlpanel, text="Next", command=self.OnSkip) volume = ttk.Button(ctrlpanel, text="Volume", command=self.OnSetVolume) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) next.pack(side=Tk.LEFT) volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) self.media_list = vlc.MediaList() self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
def _createWidgets(self): self.plot_area = ttk.Frame(self) self.plot_area.pack(side='top', fill="both") self.user_area = ttk.Frame(self) self.user_area.pack(side='bottom', fill='x') # plot stuff # TODO add a second yaxis for RH # TODO add a nice style: http://matplotlib.org/examples/style_sheets/plot_fivethirtyeight.html fig = Figure() canvas = FigureCanvasTkAgg(fig, self.plot_area) canvas.draw() toolbar = NavigationToolbar2TkAgg(canvas, self.plot_area) toolbar.update() toolbar.pack(side="top") canvas.get_tk_widget().pack(side="top", fill="both", expand=True) graph = fig.add_subplot(1, 1, 1) graph.set_ylabel("Temperature $^\circ C$", size=18) graph.set_ylim(-20, 80) graph.grid() # buttons and labels stuff ## buttons self.buttons_area = ttk.Frame(self.user_area) self.buttons_area.pack(side='right', fill='y') self.buttons_area.rowconfigure(0, weight=1, uniform=1) self.buttons_area.rowconfigure(1, weight=1, uniform=1) self.startButton = ttk.Button(self.buttons_area, text='Start') self.stopButton = ttk.Button(self.buttons_area, text='Stop', command=self.quit) self.startButton.grid(row=0) self.stopButton.grid(row=1) ## labels self.labels_area = ttk.Frame(self.user_area) self.labels_area.pack(side='left', fill='y') self.TempLabel = ttk.Label(self.labels_area, text=u"Current Temperature:") self.HumLabel = ttk.Label(self.labels_area, text=u"Current Humidity:") self.TempLabel.grid(row=0, sticky='W') self.HumLabel.grid(row=1, sticky='W') self.lastTempLabel = ttk.Label(self.labels_area, textvariable=self.lastTemperature) self.lastHumLabel = ttk.Label(self.labels_area, textvariable=self.lastHumidity) self.lastTempLabel.grid(row=0, column=1, sticky='W') self.lastHumLabel.grid(row=1, column=1, sticky='W')
def _init_view(self): """Método de creación de vista. En este método es donde realmente se genera la vista de la, ventana pues es donde se crean todos los widgets y se colocán, en su lugar correspondiente. """ # Creamos el marco self._principal_frame = ttk.Frame(self._window.get(), padding="3 3 12 12") # El marco está en la posición 0,0 de la ventana en el centro self._principal_frame.grid(column=0, row=0, sticky='NSEW') # cantidad de columnas que tiene el marco self._principal_frame.columnconfigure(0, weight=1) # cantidad de filas que tiene el marco self._principal_frame.rowconfigure(0, weight=1) # crea bóton dentro de marco self.b_back = ttk.Button(self._principal_frame, text="Atras") # ponemos en la posición 0,0 y que se expanda a SurEste self.b_back.grid(column=7, row=7, sticky='SE') # agregamos el comando del bóton # FIXME: Arreglar el botón hacia atras para volver a la vista anterior self.b_back.bind("<Button>", self._controller.back) self._add_menu("MenuVista2") self._add_item_menu("MenuVista2", "Prueba", self._controller.back)
def CreateSettingsFrame(self, widgetholder): frame = ttk.Frame(self, borderwidth=5, relief='sunken') button = tk.Button(frame, text='Apply', command=self.OnSettingsApply) button2 = tk.Button(frame, text='Cancel', command=self.OnSettingsBack) widgetholder.AddVariableLabel(frame, 'range') widgetholder.AddVariableLabel(frame, 'startlabel') # widgetholder.Data['range'].set('Time Series Range Limit [{0}]'.format(self.TimeAxisVariable)) #label = tk.Label(frame, text='Time Series Range Limit [{0}]'.format(self.TimeAxisVariable)) widgetholder.AddEntry(frame, 'cutoff') # label_start = tk.Label(frame, text='Time Series Start [{0}]'.format(self.TimeAxisVariable)) widgetholder.AddEntry(frame, 'start') widgetholder.AddRadioButtons(frame, 'source', self.SourceOptions) widgetholder.Data['source'].set(self.SourceOptions[0]) buttonrow = 5 frame.grid(row=0, column=0) button.grid(row=buttonrow, column=2) button2.grid(row=buttonrow, column=0) widgetholder.Widgets['range'].grid(row=0, column=0, columnspan=3) widgetholder.Widgets['cutoff'].grid(row=1, column=0, columnspan=3) widgetholder.Widgets['startlabel'].grid(row=2, column=0, columnspan=3) widgetholder.Widgets['start'].grid(row=3, column=0, columnspan=3) widgies = widgetholder.Widgets['source'] for i in range(0, len(widgies)): widgies[i].grid(row=4, column=i) return frame
def __init__(self, parent, parameters=None): ttk.Frame.__init__(self, parent) self.Parameters = utils.Parameters() if parameters is not None: self.Parameters = parameters self.OnSettingsCallback = self.OnSettings_Stub self.WidgetHolder = WidgetHolder() inner_frame = ttk.Frame(self, borderwidth=5, relief='sunken', width=self.Parameters.MinWidth, height=self.Parameters.MinHeight) widgetholder = self.WidgetHolder widgetholder.AddButton(self, 'closer', 'Close', command=self.OnClose) widgetholder.AddListBox(self, 'equationlist', height=30) button = ttk.Button(self, text='Settings', command=self.OnSettings) widgetholder.AddEntry(self, 'equation', readonly=True) widgetholder.AddEntry(self, 'description', readonly=True) widgetholder.AddMatplotLib(self, 'graph') widgetholder.Widgets['equationlist'].bind('<<ListboxSelect>>', self.OnListEvent) # Need to give the Parameters object the equationlist widget self.Parameters.TimeSeriesWidget = widgetholder.Data['equationlist'] # Gridding self.grid(column=0, row=0, sticky=('N', 'S', 'E', 'W')) inner_frame.grid(row=0, column=0, rowspan=5, columnspan=3, sticky=('N', 'S', 'E', 'W')) widgetholder.Widgets['equationlist'].grid(row=0, column=0, columnspan=1, rowspan=3, sticky=['n', 'w', 'e', 'S']) button.grid(column=5, row=0) widgetholder.Widgets['closer'].grid(column=6, row=0) widgetholder.Widgets['description'].grid(row=0, column=1, columnspan=4, sticky=['w', 'e']) widgetholder.Widgets['equation'].grid(row=1, column=1, columnspan=6, sticky=['w', 'e']) widgetholder.GetMatplotlibInfo('graph', 'canvas').get_tk_widget().grid( column=2, row=2, columnspan=5, sticky=['n', 's', 'e', 'w']) self.columnconfigure(2, weight=1) self.columnconfigure(3, weight=1) self.columnconfigure(4, weight=1) self.rowconfigure(2, weight=1) self.UpdateEquationList()
def __init__(self, master, frameref, max, dirname, filename, originaldir): Tk.Frame.__init__(self, master) os.chdir(originaldir) master.bind("<Right>", self.next_key) master.bind("<Left>", self.back_key) print(frameref, max, dirname, filename, originaldir) self.frameref = int(frameref) self.max = max self.dirname = dirname self.originaldir = originaldir master.iconbitmap('flam.ico') master.title("FLIR_SEGMENT_FLAGGER") ctrlpanel = ttk.Frame(self.master) self.imagepanel = ttk.Frame(self.master) self.imagepanel1 = Tk.Canvas(self.imagepanel, bg='Navy') master.geometry('1920x1080') self.filename = filename[:-4] self.index = 1 if self.frameref > max: self.frameref = max self.change() next_button = Tk.Button(ctrlpanel, text="Next", command=self.next_key) back_button = Tk.Button(ctrlpanel, text="Back", command=self.back_key) self.flag_button = Tk.Button( ctrlpanel, text="Flag Start", bg='green', command=lambda: self.Flag(self.flag_button, self.index)) output_json_button = Tk.Button( ctrlpanel, text='Output JSON', bg='yellow', command=lambda: self.outputjson(self.filename)) self.flag_button.pack(side=Tk.LEFT) next_button.pack(side=Tk.LEFT) back_button.pack(side=Tk.LEFT) output_json_button.pack(side=Tk.LEFT) ctrlpanel.pack(side=Tk.TOP) self.imagepanel.pack(fill=Tk.BOTH, expand=1) self.imagepanel1.pack(fill=Tk.BOTH, expand=1)
def view_results(self, results): # https://blog.tecladocode.com/tkinter-scrollable-frames/ popup = tk.Tk() container = ttk.Frame(popup) canvas = tk.Canvas(container) scrollbar = ttk.Scrollbar(container, orient="vertical", command=canvas.yview) scrollable_frame = ttk.Frame(canvas) scrollable_frame.bind( "<Configure>", lambda e: canvas.configure(scrollregion=canvas.bbox("all"))) canvas.create_window((0, 0), window=scrollable_frame, anchor="nw") canvas.configure(yscrollcommand=scrollbar.set) self.build_results(results, scrollable_frame) container.pack(fill="both") canvas.pack(side="left", fill="both", expand=True) scrollbar.pack(side="right", fill="y") popup.mainloop()
def __place_widgets(self): # header frame and its widgets hframe = ttk.Frame(self) lbtn = ttk.Button(hframe, style='L.TButton', command=self._prev_month) rbtn = ttk.Button(hframe, style='R.TButton', command=self._next_month) self._header = ttk.Label(hframe, width=15, anchor='center') # the calendar self._calendar = ttk.Treeview(self, show='', selectmode='none', height=7) # pack the widgets hframe.pack(in_=self, side='top', pady=4, anchor='center') lbtn.grid(in_=hframe) self._header.grid(in_=hframe, column=1, row=0, padx=12) rbtn.grid(in_=hframe, column=2, row=0) self._calendar.pack(in_=self, expand=1, fill='both', side='bottom')
def __init__(self, parent, parameters=None): ttk.Frame.__init__(self, parent) self.Parameters = utils.Parameters() self.OnCloseCallback = self.CloseStub # self.SourceOptions = self.Parameters.SourceOptions if parameters is not None: self.Parameters = parameters self.WidgetHolder = WidgetHolder() frame = ttk.Frame(self, borderwidth=5, relief='sunken', width=self.Parameters.MinWidth, height=self.Parameters.MinHeight) widgetholder = self.WidgetHolder button = ttk.Button(self, text='Apply', command=self.OnSettingsApply) button2 = ttk.Button(self, text='Cancel', command=self.OnSettingsBack) widgetholder.AddVariableLabel(self, 'range') widgetholder.AddVariableLabel(self, 'startlabel') widgetholder.Data['startlabel'].set('Start') widgetholder.Data['range'].set('Time Series Range Limit [{0}]'.format( self.Parameters.TimeAxisVariable)) widgetholder.AddEntry(self, 'cutoff') widgetholder.Data['cutoff'].set(self.Parameters.TimeRange) # label_start = tk.Label(frame, text='Time Series Start [{0}]'.format(self.TimeAxisVariable)) widgetholder.AddEntry(self, 'start') widgetholder.Data['start'].set(self.Parameters.TimeStart) widgetholder.AddRadioButtons(self, 'source', self.Parameters.SourceOptions) widgetholder.Data['source'].set(self.Parameters.LastSource) buttonrow = 5 self.grid(row=0, column=0, sticky=('N', 'W')) frame.grid(row=0, column=0, columnspan=5, rowspan=5, sticky=('N', 'W')) button.grid(row=buttonrow, column=2) button2.grid(row=buttonrow, column=0) widgetholder.Widgets['range'].grid(row=0, column=0, columnspan=3) widgetholder.Widgets['cutoff'].grid(row=1, column=0, columnspan=3) widgetholder.Widgets['startlabel'].grid(row=2, column=0, columnspan=3) widgetholder.Widgets['start'].grid(row=3, column=0, columnspan=3) widgies = widgetholder.Widgets['source'] for i in range(0, len(widgies)): widgies[i].grid(row=4, column=i)
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH,expand=1) self.videopanel.pack(fill=Tk.BOTH,expand=1) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() self.begin() self.parent.update()
def _init_view(self): """Método de creación de vista. En este método es donde realmente se genera la vista de la, ventana pues es donde se crean todos los widgets y se colocán, en su lugar correspondiente. """ # Creamos el marco self._principal_frame = ttk.Frame(self._window.get(), padding="3 3 12 12") # El marco está en la posición 0,0 de la ventana en el centro self._principal_frame.grid(column=0, row=0, sticky='N' + 'S' + 'E' + 'W') # cantidad de columnas que tiene el marco self._principal_frame.columnconfigure(0, weight=1) # cantidad de filas que tiene el marco self._principal_frame.rowconfigure(0, weight=1) # crea bóton dentro de marco self.b_exit = ttk.Button(self._principal_frame, text="Exit") # ponemos en la posición 0,1 y que se expanda a SurEste self.b_exit.grid(column=12, row=12, sticky='SE') # agregamos el comando del bóton self.b_exit.bind("<Button>", self._controller.exit_application) self.b_test = ttk.Button(self._principal_frame, text="Test") self.b_test.grid(column=1, row=0, sticky='SE') self.b_test.bind("<Button>", self._controller.test) # -------------------------------------------------------------------------------- self.b_change_size = ttk.Button(self._principal_frame, text="Change Size") self.b_change_size.grid(column=0, row=0, sticky='NW') self.b_change_size.bind("<Button>", self._controller.change_size) self.b_new_view = ttk.Button(self._principal_frame, text="New View") self.b_new_view.grid(column=0, row=1, sticky='S') self.b_new_view.bind("<Button>", self._controller.new_view) self._add_menu("MenuVista1") self._add_item_menu("MenuVista1", "Prueba", self._controller.menu_item_exit)
def _setup_widgets(self): s = """\ click on header to sort by that column to change width of column drag boundary """ msg = ttk.Label(wraplength="4i", justify="left", anchor="n", padding=(10, 2, 10, 6), text=s) msg.pack(fill='x') container = ttk.Frame() container.pack(fill='both', expand=True) # create a treeview with dual scrollbars self.tree = ttk.Treeview(columns=car_header, show="headings") vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview) hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview) self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set) self.tree.grid(column=0, row=0, sticky='nsew', in_=container) vsb.grid(column=1, row=0, sticky='ns', in_=container) hsb.grid(column=0, row=1, sticky='ew', in_=container) container.grid_columnconfigure(0, weight=1) container.grid_rowconfigure(0, weight=1)
def CreateGraphFrame(self, widgetholder): content = ttk.Frame(self, borderwidth=5, relief='sunken') widgetholder.AddListBox(content, 'equationlist', height=30) button = tk.Button(content, text='Settings', command=self.OnButtonClick) button2 = tk.Button(content, text='Close', command=self.destroy) widgetholder.AddEntry(content, 'equation', readonly=True) widgetholder.AddEntry(content, 'description', readonly=True) widgetholder.AddMatplotLib(content, 'graph') widgetholder.Widgets['equationlist'].bind('<<ListboxSelect>>', self.OnListEvent) # Gridding content.grid(column=0, row=0) widgetholder.Widgets['equationlist'].grid(row=0, column=0, columnspan=1, rowspan=3, sticky=['n', 'w', 'e']) button.grid(column=5, row=0) button2.grid(column=6, row=0) widgetholder.Widgets['description'].grid(row=0, column=1, columnspan=4, sticky=['w', 'e']) widgetholder.Widgets['equation'].grid(row=1, column=1, columnspan=6, sticky=['w', 'e']) widgetholder.GetMatplotlibInfo('graph', 'canvas').get_tk_widget().grid( column=2, row=2, columnspan=5, sticky=['n', 's', 'e', 'w']) content.columnconfigure(2, weight=1) content.columnconfigure(3, weight=1) content.columnconfigure(4, weight=1) content.rowconfigure(2, weight=1) return content
def CreateModelViewer(self, widgetholder): frame = ttk.Frame(self) inner_frame = ttk.Frame(frame, borderwidth=5, relief='sunken', width=self.MinWidth, height=self.MinHeight) top_frame = ttk.Frame(frame, borderwidth=5, relief='sunken') widgetholder.AddVariableLabel(top_frame, 'model_name') widgetholder.AddVariableLabel(top_frame, 'model_state') widgetholder.AddVariableLabel(top_frame, 'num_sector_eqn') widgetholder.AddVariableLabel(top_frame, 'num_final_eqn') widgetholder.AddButton(frame, 'back', text='Back', command=self.OnModelViewerBack) # widgetholder.AddListBox(frame, 'country', height=5, callback=self.OnChangeCountry) widgetholder.AddButton(frame, 'fullcodes', 'Generate\nFullCodes', command=self.OnGenerateFullCodes) widgetholder.AddButton(frame, 'fixaliases', 'Fix Aliases', command=self.OnFixAliases) widgetholder.AddButton(frame, 'generate_eqn', 'Generate\nEquations', command=self.OnGenerateEquations) widgetholder.AddTree(frame, 'equations', columns=('Equation', 'Comment')) # Push a configuration variable into the WidgetHolder widgetholder.Data['parameter_final_equation'] = 'Final Equations (All)' scrolly = ttk.Scrollbar( frame, orient=VERTICAL, command=self.WidgetsModelViewer.Widgets['equations'].yview) self.WidgetsModelViewer.Widgets['equations'][ 'yscrollcommand'] = scrolly.set label_name = ttk.Label(top_frame, text='Model Name: ') label_state = ttk.Label(top_frame, text="State: ") label_num_sector = ttk.Label(top_frame, text='# of Sector Equations') label_num_final = ttk.Label(top_frame, text='# of Final Equations') # Gridding frame.grid(row=0, column=0, sticky=('N', 'S', 'E', 'W')) # Top Grid top_frame.grid(row=0, column=0, columnspan=5, sticky=('W', )) label_name.grid(row=0, column=0) self.WidgetsModelViewer.Widgets['model_name'].grid(row=0, column=1, padx=5) label_state.grid(row=0, column=2, sticky=('E')) self.WidgetsModelViewer.Widgets['model_state'].grid(row=0, column=3, padx=5) label_num_sector.grid(row=1, column=0) self.WidgetsModelViewer.Widgets['num_sector_eqn'].grid(row=1, column=1, padx=5, sticky=('W', )) label_num_final.grid(row=1, column=2) self.WidgetsModelViewer.Widgets['num_final_eqn'].grid(row=1, column=3, padx=5, sticky=('W', )) self.WidgetsModelViewer.Widgets['back'].grid(row=0, column=4, sticky=('E')) self.WidgetsModelViewer.Widgets['equations'].grid(row=1, column=0, columnspan=5, rowspan=5, sticky=('N', 'S', 'W', 'E')) scrolly.grid(row=1, column=6, rowspan=3, sticky=('N', 'S')) # self.WidgetsModelViewer.Widgets['fullcodes'].grid(row=1, column=4, sticky=('N', 'E')) # self.WidgetsModelViewer.Widgets['fixaliases'].grid(row=2, column=4, sticky=('N', 'E')) # self.WidgetsModelViewer.Widgets['generate_eqn'].grid(row=3, column=4, sticky=('N', 'E')) inner_frame.grid(row=0, column=0, rowspan=5, columnspan=6, sticky=('N', 'S', 'E', 'W')) #frame.columnconfigure(0, weight=1) #frame.columnconfigure(1, weight=1) #frame.columnconfigure(2, weight=1) #frame.columnconfigure(3, weight=1) frame.columnconfigure(4, weight=2) frame.rowconfigure(1, weight=1) frame.rowconfigure(2, weight=1) frame.rowconfigure(3, weight=1) run_frame = ttk.LabelFrame(frame, text='Run') run_frame.grid(row=0, column=7, rowspan=5, sticky=('N', 'S', 'E', 'W')) widgetholder.AddButton(run_frame, 'reload', 'Reload', command=self.OnRunModel) label_next_step = ttk.Label(run_frame, text='Next Step:', width=25) widgetholder.AddButton(run_frame, 'run_next', 'Run Next Step', command=self.OnRunNext) widgetholder.AddButton(run_frame, 'run_all', 'Run All Steps', command=self.OnRunAll) widgetholder.AddVariableLabel(run_frame, 'next_step') label_choose_next = ttk.Label(run_frame, text='Possible Choices') widgetholder.AddListBox(run_frame, 'possible_steps', height=7, single_select=True, callback=self.UpdateModelViewer) widgetholder.AddButton(run_frame, 'show_graph', 'Show Graph', command=self.OnShowGraph) widgetholder.Widgets['reload'].grid(row=0, column=0) label_next_step.grid(row=1, column=0, pady=(10, 0)) widgetholder.Widgets['next_step'].grid(row=2, column=0) widgetholder.Widgets['run_next'].grid(row=3, column=0) label_choose_next.grid(row=4, column=0) widgetholder.Widgets['possible_steps'].grid(row=5, column=0) widgetholder.Widgets['run_all'].grid(row=6, column=0, pady=20) widgetholder.Widgets['show_graph'].grid(row=7, column=0, pady=20) return frame
def __init__(self, parent, video=''): Tk.Frame.__init__(self, parent, height=800, width=400) self.parent = parent # == root # self.parent.title(title or "tkVLCplayer") # self.video = expanduser(video) self.video = video self._resized = False # Menu Bar # File Menu # menubar = Tk.Menu(self.parent) # self.parent.config(menu=menubar) # fileMenu = _Tk_Menu(menubar) # fileMenu.bind_shortcuts_to(parent) # XXX must be root? # fileMenu.add_shortcut("Open...", 'o', self.OnOpen) # fileMenu.add_separator() # fileMenu.add_shortcut("Play", 'p', self.OnPlay) # Play/Pause # fileMenu.add_command(label="Stop", command=self.OnStop) # fileMenu.add_separator() # fileMenu.add_shortcut("Mute", 'm', self.OnMute) # fileMenu.add_separator() # fileMenu.add_shortcut("Close", 'w' if _isMacOS else 's', self.OnClose) # if _isMacOS: # intended for and tested on macOS # fileMenu.add_separator() # fileMenu.add_shortcut("Full Screen", 'f', self.OnFullScreen) # menubar.add_cascade(label="File", menu=fileMenu) # self.fileMenu = fileMenu # self.playIndex = fileMenu.index("Play") # self.muteIndex = fileMenu.index("Mute") # first, top panel shows video # u, v = self.player.video_get_size() # often (0, 0 self.videopanel = ttk.Frame(self, width=400, height=800) self.canvas = Tk.Canvas(self.videopanel, background='grey', width=500, height=900) self.canvas.pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(expand=1) #self.videopanel.place(relx=0.324, rely=0.053) self.videopanel.place(relx=0, rely=0) # panel to hold buttons # self.buttons_panel = Tk.Toplevel(self.parent) # self.buttons_panel.title("") # self.is_buttons_panel_anchor_active = False # buttons = ttk.Frame(self.buttons_panel) # self.playButton = ttk.Button(buttons, text="Play", command=self.OnPlay) # stop = ttk.Button(buttons, text="Stop", command=self.OnStop) # self.muteButton = ttk.Button(buttons, text="Mute", command=self.OnMute) # self.playButton.pack(side=Tk.LEFT) # stop.pack(side=Tk.LEFT) # self.muteButton.pack(side=Tk.LEFT) # self.volMuted = False # self.volVar = Tk.IntVar() # self.volSlider = Tk.Scale(buttons, variable=self.volVar, command=self.OnVolume, # from_=0, to=100, orient=Tk.HORIZONTAL, length=200, # showvalue=0, label='Volume') # self.volSlider.pack(side=Tk.RIGHT) # buttons.pack(side=Tk.BOTTOM, fill=Tk.X) # # panel to hold player time slider # timers = ttk.Frame(self.buttons_panel) # self.timeVar = Tk.DoubleVar() # self.timeSliderLast = 0 # self.timeSlider = Tk.Scale(timers, variable=self.timeVar, command=self.OnTime, # from_=0, to=1000, orient=Tk.HORIZONTAL, length=500, # showvalue=0) # label='Time', # self.timeSlider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) # self.timeSliderUpdate = time.time() # timers.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player args = ["--reset-plugins-cache"] self.Instance = vlc.Instance(args) self.player = self.Instance.media_player_new() self.parent.bind("<Configure>", self.OnConfigure) # catch window resize, etc. self.parent.update() # After parent.update() otherwise panel is ignored. # self.buttons_panel.overrideredirect(True) # Estetic, to keep our video panel at least as wide as our buttons panel. # self.parent.minsize(width=502, height=0) # if _isMacOS: # # Only tested on MacOS so far. Enable for other OS after verified tests. # self.is_buttons_panel_anchor_active = True # # Detect dragging of the buttons panel. # self.buttons_panel.bind("<Button-1>", lambda event: setattr(self, "has_clicked_on_buttons_panel", event.y < 0)) # self.buttons_panel.bind("<B1-Motion>", self._DetectButtonsPanelDragging) # self.buttons_panel.bind("<ButtonRelease-1>", lambda _: setattr(self, "has_clicked_on_buttons_panel", False)) # self.has_clicked_on_buttons_panel = False # else: # self.is_buttons_panel_anchor_active = False # self._AnchorButtonsPanel() self.OnTick() # set the timer up
def __init__(self, parent, title=None, video=''): Tk.Frame.__init__(self, parent) self.parent = parent # == root self.parent.title(title or "tkVLCplayer") self.video = expanduser(video) # Menu Bar # File Menu menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = _Tk_Menu(menubar) fileMenu.bind_shortcuts_to(parent) # XXX must be root? fileMenu.add_shortcut("Open...", 'o', self.OnOpen) fileMenu.add_separator() fileMenu.add_shortcut("Play", 'p', self.OnPlay) # Play/Pause fileMenu.add_command(label="Stop", command=self.OnStop) fileMenu.add_separator() fileMenu.add_shortcut("Mute", 'm', self.OnMute) fileMenu.add_separator() fileMenu.add_shortcut("Close", 'w' if _isMacOS else 's', self.OnClose) if _isMacOS: # intended for and tested on macOS fileMenu.add_separator() fileMenu.add_shortcut("Full Screen", 'f', self.OnFullScreen) menubar.add_cascade(label="File", menu=fileMenu) self.fileMenu = fileMenu self.playIndex = fileMenu.index("Play") self.muteIndex = fileMenu.index("Mute") # first, top panel shows video self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel) self.canvas.pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) # panel to hold buttons buttons = ttk.Frame(self.parent) self.playButton = ttk.Button(buttons, text="Play", command=self.OnPlay) stop = ttk.Button(buttons, text="Stop", command=self.OnStop) self.muteButton = ttk.Button(buttons, text="Mute", command=self.OnMute) self.playButton.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) self.muteButton.pack(side=Tk.LEFT) self.volMuted = False self.volVar = Tk.IntVar() self.volSlider = Tk.Scale(buttons, variable=self.volVar, command=self.OnVolume, from_=0, to=100, orient=Tk.HORIZONTAL, length=200, showvalue=0, label='Volume') self.volSlider.pack(side=Tk.LEFT) buttons.pack(side=Tk.BOTTOM) # panel to hold player time slider timers = ttk.Frame(self.parent) self.timeVar = Tk.DoubleVar() self.timeSliderLast = 0 self.timeSlider = Tk.Scale(timers, variable=self.timeVar, command=self.OnTime, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500, showvalue=0) # label='Time', self.timeSlider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeSliderUpdate = time.time() timers.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player args = [] if _isLinux: args.append('--no-xlib') self.Instance = vlc.Instance(args) #self.player = self.Instance.media_player_new(http://icecast.vrtcdn.be/stubru-high.mp3,network-caching=1000) self.player = self.Instance.media_player_new() self.media = self.instance.media_new( 'http://icecast.vrtcdn.be/stubru-high.mp3', " network-caching=1000") self.media.get_mrl() self.player.set_media(media) self.parent.bind("<Configure>", self.OnConfigure) # catch window resize, etc. self.parent.update() self.OnTick() # set the timer up
def __init__(self, master): # formating window to have meaningful label and nice colours master.title('Silk Road Historic Feature Data Collection') master.configure(background = '#00000') # add in some window-universal styling self.style = ttk.Style() self.style.configure('TFrame', background = '#7387ed') self.style.configure('TButton', background = '#7387ed') self.style.configure('TLabelFrame', background = '#7387ed', font=('Arial', 12)) self.style.configure('TLabel', background = '#7387ed', font = ('Arial', 11)) self.style.configure('Header.TLabel', font = ('Arial', 18, 'bold')) # creating header frame and using pack geometry master to place at # top of window. This frame thanks user for contributing data. self.frame_header = ttk.Frame(master) self.frame_header.pack() ttk.Label(self.frame_header, text = "Thank you for sharing information about the Silk Road!", font = ('Arial', 14), background = '#7387ed').pack(pady=5) # creating a second frame in window - this time using the LabelFrame # constructor, so that the Location data being collected is made # distinct from other data types to avoid confusion about state (i.e., # want location and not current status). Using pack geometry manager to # add frame under header. self.frame_loc = ttk.Labelframe(master, text="Location of Historic Feature") self.frame_loc.pack() # creating labels for each of the location inputs ttk.Label(self.frame_loc, text = "City:").grid(row = 0, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_loc, text = "State:").grid(row = 2, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_loc, text = "Country:").grid(row = 4, column = 0, pady = 3, sticky = 'sw') # creating Entry widgets for user input of location info self.entry_city = ttk.Entry(self.frame_loc, width = 50, font = ('Arial', 11)) self.entry_state = ttk.Entry(self.frame_loc, width = 50, font = ('Arial', 11)) self.entry_country = ttk.Entry(self.frame_loc, width = 50, font =('Arial', 11)) # using grid geometry manager on entry widgets self.entry_city.grid(row = 1, column = 0) self.entry_state.grid(row = 3, column = 0) self.entry_country.grid(row = 5, column = 0) # creating another LabelFrame for Feature Detail section. Using pack # geometry mananger to add it under the Location frame. self.frame_details = ttk.Labelframe(master, text = "Feature Details") self.frame_details.pack() # creating Label widgets for each input ttk.Label(self.frame_details, text = "Name of Feature:").grid(row=0, column = 0, pady = 3, sticky = 'sw') ttk.Label(self.frame_details, text = "Type of Feature:").grid(row=2, column=0, pady = 3, sticky = 'sw') # creating widgets for feature details; name will be an Entry widget and # type will be a text widget to allow multi-line entry self.entry_name = ttk.Entry(self.frame_details, width = 60, font = ('Arial', 11)) self.text_type = Text(self.frame_details, width = 60, height = 10, font = ('Arial', 11)) # using grid geometry manager on feature detail widgets self.entry_name.grid(row = 1, column = 0) self.text_type.grid(row = 3, column = 0) # create buttons for Submit and Clear options. Submit sends data and # then the data is cleared from the fields ready for next entry. Clear # deletes all information from all fields. ttk.Button(self.frame_details, text = "Submit", command = self.submit).grid(row = 4, column = 0, pady=5) ttk.Button(self.frame_details, text = "Clear", command = self.clear).grid(row = 4, column = 1, pady=5)
def __init__(self, parent, title=None, video=''): Tk.Frame.__init__(self, parent) self.parent = parent self.parent.title(title or "tkVLCplayer") self.video = video # Menu Bar # File Menu menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Tk.Menu(menubar) fileMenu.add_command(**_shortcut("Open", 'O', self.OnOpen)) fileMenu.add_separator() fileMenu.add_command(label="Play", command=self.OnPlay) fileMenu.add_command(**_shortcut("Pause", 'P', self.OnPause)) fileMenu.add_command(label="Stop", command=self.OnStop) fileMenu.add_separator() fileMenu.add_command(**_shortcut("Mute", 'M', self.OnSetVolume)) fileMenu.add_separator() fileMenu.add_command(**_shortcut("Exit", 'X', _quit)) menubar.add_cascade(label="File", menu=fileMenu) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) volume = ttk.Button(ctrlpanel, text="Mute", command=self.OnSetVolume) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() # below is a test, now use the File->Open file menu #media = self.Instance.media_new('output.mp4') #self.player.set_media(media) #self.player.play() # hit the player button #self.player.video_set_deinterlace(str_to_bytes('yadif')) self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "FLIR_SEGMENT_FLAGGER" self.parent.title(title) self.parent.iconbitmap('flam.ico') # Menu Bar # File Menu menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Tk.Menu(menubar) fileMenu.add_command(label="Open", underline=0, command=self.OnOpen) fileMenu.add_command(label="Exit", underline=1, command=_quit) menubar.add_cascade(label="File", menu=fileMenu) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) flag = ttk.Button( ctrlpanel, text="Flag", command=lambda: [f() for f in [self.OnPause, self.OnFlag]]) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) volume = ttk.Button(ctrlpanel, text="Volume", command=self.OnSetVolume) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) flag.pack(side=Tk.LEFT) volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() # below is a test, now use the File->Open file menu #media = self.Instance.media_new('output.mp4') #self.player.set_media(media) #self.player.play() # hit the player button #self.player.video_set_deinterlace(str_to_bytes('yadif')) self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
def __init__(self, parent, title=None): global index Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) fileMenu = Tk.Menu(menubar) fileMenu.add_command(label="Open", underline=0, command=self.OnOpen) fileMenu.add_command(label="Exit", underline=1, command=_quit) menubar.add_cascade(label="File", menu=fileMenu) self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) ctrlpanel = ttk.Frame(self.parent) ctrlpanel3 = ttk.Frame(self.parent) ctrlpanel2 = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) saveVideo = ttk.Button(ctrlpanel, text="Screenshot", command=self.saveVideo) plus5 = ttk.Button(ctrlpanel, text="plus5", command=self.plus5) minus5 = ttk.Button(ctrlpanel, text="minus5", command=self.minus5) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) global filename_store, directory_store, fullname textBox = Text(ctrlpanel3, height=1, width=10) textBox.pack() text_buttonAdd = Button( ctrlpanel3, height=1, width=15, text="Add new button", command=lambda: [ ttk.Button(ctrlpanel2, text=textBox.get("1.0", "end-1c"), command=lambda dummy=textBox.get("1.0", "end-1c"): self.click_event(dummy)).pack(side="left"), os.mkdir(directory_store + '/' + textBox.get("1.0", "end-1c")) ]) text_buttonAdd.pack(side="left") pause.pack(side=Tk.LEFT) saveVideo.pack(side=Tk.LEFT) plus5.pack(side=Tk.LEFT) minus5.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM) ctrlpanel3.pack(side=Tk.BOTTOM) ctrlpanel.pack(side=Tk.BOTTOM) self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
def __init__(self, parent, title=None): self.lastValue = '' Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) style = ttk.Style() style.configure("BW.TLabel", foreground="black", background="black") # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent, style="BW.TLabel") # self.videopanel.config(bg="black") self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) #frame = ttk.Frame(root, width=1000, height=1000) self.videopanel.bind("<Button-1>", self.pressedOne) self.videopanel.bind("<Double-Button-1>", self.pressedTwo) ctrlpanel = ttk.Frame(self.parent, style="BW.TLabel") pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) load = ttk.Button(ctrlpanel, text="LoadMain", command=self.OnLoad) loadB = ttk.Button(ctrlpanel, text="LoadTemp", command=self.OnLoadB) self.blackFrame = ttk.Frame(self.parent, style="BW.TLabel") self.blackFrame.place(x=0, y=0, width=root.winfo_screenwidth(), height=root.winfo_screenheight()) self.blackFrame.bind("<Button-1>", self.pressedOne) # pause.pack(side=Tk.LEFT) # play.pack(side=Tk.LEFT) # stop.pack(side=Tk.LEFT) # load.pack(side=Tk.LEFT) loadB.pack(side=Tk.LEFT) ctrlpanel2 = ttk.Frame(self.parent, style="BW.TLabel") self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() # ctrlpanel.pack(side=Tk.BOTTOM) #ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player controls self.Instance = vlc.Instance('--no-xlib --verbose=0') self.player = self.Instance.media_player_new() self.player.audio_set_volume(100) self.player.video_set_scale(0) self.player.video_set_aspect_ratio('16:9') self.player.video_set_deinterlace('on') # self.player.set_fullscreen(True) # below is a test, now use the File->Open file menu media = self.Instance.media_new(video) self.player.set_media(media) # self.player.play() # hit the player button # self.player.video_set_deinterlace(str_to_bytes('yadif')) self.timer = ttkTimer(self.OnTimer, 0.5) self.timer.start() self.parent.update()
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.songURL = "EMPTY" self.songLabels = [] # list for names of songs self.webcamLbl = ttk.Label() # webcam image widget label self.photoTaken = False self.webcam = cv2.VideoCapture(0) self.updateB = True # bool to start and stop webcam update self.lastURL = "EMPTY" self.speed = 10 # milliseconds between UI refresh self.songs = [] self.songCounter = 0 self.parent = parent self.emotion = "" self.shutter = 0 self.curated = True if title == None: title = "tk_vlc" self.parent.title(title) self.topMaster = ttk.Frame(self.parent) self.topPanel = ttk.Frame(self.topMaster) self.topPanelR = ttk.Frame(self.topMaster) #self.songName = ttk.Label(self.topPanel, text="Song: N/A") self.songName = ttk.Label(self.topPanel, text="Song: N/A") self.artistName = ttk.Label(self.topPanel, text="Artist: N/A") self.emotionLabel = ttk.Label(self.topPanel, text="Emotion: N/A") self.webCamButton = ttk.Button(self.topPanelR, text="Webcam Active", command=self.activateWebcam, width=15) self.shutter = ttk.Button(self.topPanelR, text="Take Photo", command=self.takethephoto, width=15) photostripButton = ttk.Button(self.topPanelR, text="Photostrip", command=self.browseFile, width=15) self.songName.grid(row=0, column=0, sticky=Tk.W) self.artistName.grid(row=1, column=0, sticky=Tk.W) self.emotionLabel.grid(row=2, column=0, sticky=Tk.W) photostripButton.grid(row=1, column=1, sticky=Tk.E) self.shutter.grid(row=0, column=0, rowspan=2, sticky=Tk.E, ipady=13) self.webCamButton.grid(row=0, column=1, sticky=Tk.E) self.topPanel.pack(fill=Tk.BOTH, side=Tk.LEFT) self.topPanelR.pack(fill=Tk.BOTH, side=Tk.RIGHT) self.topMaster.pack(fill=Tk.BOTH, side=Tk.TOP) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) image = im.open("artwork/default.jpg") photo = image imgtk = imTk.PhotoImage(image=image) self.webcamLbl = ttk.Label(self.videopanel, image=imgtk, text="Stream") self.webcamLbl.image = imgtk self.webcamLbl.pack(side=Tk.BOTTOM) self.videopanel.pack(fill=Tk.BOTH, expand=1) self.videopanel.pack_propagate(False) self.videopanel["width"] = 650 self.videopanel["height"] = 500 ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause) play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay) stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop) volume = ttk.Label(ctrlpanel, text="Volume") self.nextButton = ttk.Button(ctrlpanel, text="Next", command=self.OnNext) self.prevButton = ttk.Button(ctrlpanel, text="Previous", command=self.OnPrev) self.prevButton.pack(side=Tk.LEFT) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) self.nextButton.pack(side=Tk.LEFT) self.nextButton["state"] = "disabled" self.prevButton["state"] = "disabled" volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) self.volume_var.set(50) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) ctrlpanel3 = ttk.Frame(self.parent) self.curated = Tk.IntVar() self.curateCheck = ttk.Checkbutton(ctrlpanel3, text="Curate", variable=self.curated) self.curated.set(1) self.curateCheck.pack(side=Tk.RIGHT) self.message = ttk.Label(ctrlpanel3, text="Status: Ready to take photo.") self.message.pack(side=Tk.LEFT) self.share = ttk.Button(ctrlpanel3, text="Share", command=self.share) self.share.pack(side=Tk.RIGHT) self.inputText = ttk.Entry(ctrlpanel3, width=15) self.inputText.pack(side=Tk.RIGHT) self.instruction = ttk.Label(ctrlpanel3, text="Your name: ") self.instruction.pack(side=Tk.RIGHT) ctrlpanel3.pack(fill=Tk.BOTH, side=Tk.TOP) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() #self.player.audio_set_volume(100) self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
from Tkinter import * from Tkinter import ttk def calculate(*args): try: value = float(feet.get()) meters.set((0.3048 * value * 10000.0 + 0.5) / 10000.0) except ValueError: pass root = Tk() root.title("Feet to Meters") mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) feet = StringVar() meters = StringVar() feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet) feet_entry.grid(column=2, row=1, sticky=(W, E)) ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W, E)) ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W) ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W) ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E) ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5)
def __init__(self, parent, title=None): Tk.Frame.__init__(self, parent) self.parent = parent if title == None: title = "tk_vlc" self.parent.title(title) # Menu Bar # File Menu menubar = Tk.Menu(self.parent) self.parent.config(menu=menubar) folder_icon = ImageTk.PhotoImage(Image.open('./Icon/folder-icon.png')) play_icon = ImageTk.PhotoImage( Image.open('./Icon/control-play-icon.png')) stop_icon = ImageTk.PhotoImage( Image.open('./Icon/control-stop-icon.png')) pause_icon = ImageTk.PhotoImage( Image.open('./Icon/control-pause-icon.png')) volume_icon = ImageTk.PhotoImage(Image.open('./Icon/volume-icon.png')) fileMenu = Tk.Menu(menubar) fileMenu.add_command(label="Open", underline=0, command=self.OnOpen) fileMenu.add_command(label="Detect", underline=1, command=self.OnDetect) fileMenu.add_separator() fileMenu.add_command(label="Exit", underline=2, command=_quit) menubar.add_cascade(label="File", menu=fileMenu) # The second panel holds controls self.player = None self.videopanel = ttk.Frame(self.parent) self.canvas = Tk.Canvas(self.videopanel).pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) #self.controller = controller ctrlpanel = ttk.Frame(self.parent) pause = ttk.Button(ctrlpanel, image=pause_icon, command=self.OnPause) play = ttk.Button(ctrlpanel, image=play_icon, command=self.OnPlay) stop = ttk.Button(ctrlpanel, image=stop_icon, command=self.OnStop) volume = ttk.Button(ctrlpanel, image=volume_icon, command=self.OnSetVolume) self.progress = ttk.Progressbar(ctrlpanel, orient="horizontal", length=200, mode="determinate") #self.progress.bind('<Map>',self.OnDetect) self.bytes = 0 self.maxbytes = 0 pause.image = pause_icon play.image = play_icon stop.image = stop_icon volume.image = volume_icon self.progress.pack(side=Tk.LEFT) pause.pack(side=Tk.LEFT) play.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) volume.pack(side=Tk.LEFT) self.volume_var = Tk.IntVar() self.volslider = Tk.Scale(ctrlpanel, variable=self.volume_var, command=self.volume_sel, from_=0, to=100, orient=Tk.HORIZONTAL, length=100) self.volslider.pack(side=Tk.LEFT) ctrlpanel.pack(side=Tk.BOTTOM) ctrlpanel2 = ttk.Frame(self.parent) self.scale_var = Tk.DoubleVar() self.timeslider_last_val = "" self.timeslider = Tk.Scale(ctrlpanel2, variable=self.scale_var, command=self.scale_sel, from_=0, to=1000, orient=Tk.HORIZONTAL, length=500) self.timeslider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeslider_last_update = time.time() ctrlpanel2.pack(side=Tk.BOTTOM, fill=Tk.X) # VLC player controls self.Instance = vlc.Instance() self.player = self.Instance.media_player_new() # below is a test, now use the File->Open file menu #media = self.Instance.media_new('output.mp4') #self.player.set_media(media) #self.player.play() # hit the player button #self.player.video_set_deinterlace(str_to_bytes('yadif')) self.timer = ttkTimer(self.OnTimer, 1.0) self.timer.start() self.parent.update()
def __init__(self, parent, title=None, video=''): Tk.Frame.__init__(self, parent) self.compDataset = [] self.compComboOptions = ["Select Competition"] self.teamComboOptions = [] self.teamComboOptionsI = [] self.roundComboOptions = [] self.videoWt = 120 self.framesFound = 0 self.isSplitting = 0 style = ttk.Style() style.configure("TButton", padding=5, font=("Helvetica", "12")) style.configure("Player.TButton", pady=0, padx=0, font=("Helvetica", "12")) style.configure("Split.TButton", padx=5, pady=20, font=("Helvetica", "12")) style.configure("TProgressbar", pady=5) style.configure("SplitSelected.TButton", padding=5, background="green", activebackground="yellow", highlightbackground="yellow", font=("Helvetica", "20")) style.configure("Error.SplitSelected.TButton", padding=5, background="red", activebackground="red", highlightbackground="red", font=("Helvetica", "20")) self.parent = parent # == root self.parent.title(title or "Skydive Or Bust Dubbing 1.0") self.video = expanduser(video) # first, top panel shows vide self.vWrapper = ttk.Frame(self.parent) self.videopanel = ttk.Frame(self.vWrapper) self.canvas = Tk.Canvas(self.videopanel) self.canvas.pack(fill=Tk.BOTH, expand=1) self.videopanel.pack(fill=Tk.BOTH, expand=1) self.vWrapper.pack(side=Tk.LEFT) # panel to hold buttons self.buttons_panel = Tk.Frame(self.vWrapper) self.splitting_panel = Tk.Frame(self.parent) compcombo = ttk.Frame(self.buttons_panel) self.compCombo = ttk.Combobox(compcombo, width=25) self.compCombo['values'] = self.compComboOptions self.teamCombo = ttk.Combobox(compcombo, width=25) self.roundCombo = ttk.Combobox(compcombo, width=25) self.compCombo.pack(side=Tk.TOP) self.teamCombo.pack(side=Tk.TOP) self.roundCombo.pack(side=Tk.TOP) compcombo.pack(side=Tk.BOTTOM, fill=Tk.X) self.compCombo.bind('<<ComboboxSelected>>', lambda event: self.change_comp()) buttons = ttk.Frame(self.buttons_panel) self.openButton = ttk.Button(buttons, text="Open", command=self.OnOpen, style="Player.TButton") self.playButton = ttk.Button(buttons, text="Play", command=self.OnPlay, style="Player.TButton") stop = ttk.Button(buttons, text="Stop", command=self.OnStop, style="Player.TButton") eject = ttk.Button(buttons, text="Eject", command=self.OnEject, style="Player.TButton") self.slateButton = ttk.Button(self.splitting_panel, text="Slate", command=self.onMarkSlate, style="Split.TButton") self.exitButton = ttk.Button(self.splitting_panel, text="Exit", command=self.onMarkExit, style="Split.TButton") self.uploadButton = ttk.Button(self.splitting_panel, text="Upload", command=self.onUpload, style="Split.TButton") self.statusLabelH = ttk.Label(self.splitting_panel, text="Video Status:") self.progressBar = ttk.Progressbar(self.splitting_panel, orient=Tk.HORIZONTAL, length=200, mode='determinate', style="TProgressbar") self.wtLabel = ttk.Label(self.splitting_panel, text=str(self.videoWt) + "sec Working Time") self.statusLabel = ttk.Label(self.splitting_panel, text="Open Video") self.openButton.pack(side=Tk.LEFT) self.playButton.pack(side=Tk.LEFT) stop.pack(side=Tk.LEFT) eject.pack(side=Tk.LEFT) self.slateButton.pack(side=Tk.TOP) self.exitButton.pack(side=Tk.TOP) self.uploadButton.pack(side=Tk.TOP) self.statusLabelH.pack(side=Tk.TOP) self.progressBar.pack(side=Tk.TOP) self.wtLabel.pack(side=Tk.TOP) self.statusLabel.pack(side=Tk.TOP) buttons.pack(side=Tk.BOTTOM, fill=Tk.X) # panel to hold player time slider timers = ttk.Frame(self.buttons_panel) self.timeVar = Tk.DoubleVar() self.timeSliderLast = 0 self.timeSlider = Tk.Scale(timers, variable=self.timeVar, command=self.OnTime, from_=0, to=1000, orient=Tk.HORIZONTAL, length=400, showvalue=0) # label='Time', self.timeSlider.pack(side=Tk.BOTTOM, fill=Tk.X, expand=1) self.timeSliderUpdate = time.time() timers.pack(side=Tk.BOTTOM, fill=Tk.X) self.buttons_panel.pack(fill=Tk.BOTH, expand=1) self.splitting_panel.pack(fill=Tk.BOTH, expand=1) # VLC player args = [] args.append('--no-xlib') self.Instance = vlc.Instance(args) self.player = self.Instance.media_player_new() self.player.audio_set_volume(0) self.parent.bind("<Configure>", self.OnConfigure) # catch window resize, etc. self.parent.update() # After parent.update() otherwise panel is ignored. # self.buttons_panel.overrideredirect(True) # Estetic, to keep our video panel at least as wide as our buttons panel. # self.parent.minsize(width=600, height=450) self.is_buttons_panel_anchor_active = False # Download API Data self.get_comps() self.list_comps() self.OnTick() # set the timer up
def CreateChooser(self, widgetholder): frame = ttk.Frame(self) inner_frame = ttk.Frame(frame, borderwidth=5, relief='sunken', width=self.MinWidth, height=self.MinHeight) widgetholder.AddEntry(frame, 'directory') widgetholder.Data['directory'].set(os.getcwd()) label_dir = Label(frame, text='Working Directory') button_choose = ttk.Button(frame, text='Choose', command=self.OnChooseDir) widgetholder.AddEntry(frame, 'logdir') default = os.path.join(widgetholder.Data['directory'].get(), 'output') if os.path.isdir(default): logdir = default else: logdir = '' widgetholder.Data['logdir'].set(logdir) self.Parameters.LogDir = logdir # Log directory label_log = Label(frame, text='Log Directory') button_choose_log = ttk.Button(frame, text='Choose', command=self.OnChooseDir) # Model row label_model = Label(frame, text='Model File') widgetholder.AddListBox(frame, 'models', height=12) widgetholder.Widgets['models'].bind('<<ListboxSelect>>', self.OnChangeModel) widgetholder.AddEntry(frame, 'model_desc', readonly=True) widgetholder.AddVariableLabel(frame, 'is_valid') widgetholder.AddButton(frame, 'run_button', command=self.OnRunModel, text='Load', state='disabled') # Grid'em, Danno! frame.grid(row=0, column=0, rowspan=4, columnspan=3, sticky=['n', 's', 'w', 'e']) # Working directory label_dir.grid(row=0, column=0) widgetholder.Widgets['directory'].grid(row=0, column=1, sticky=['w', 'e']) button_choose.grid(row=0, column=2, sticky='w', padx=5) # Log dir label_log.grid(row=1, column=0) widgetholder.Widgets['logdir'].grid(row=1, column=1, sticky=['w', 'e']) button_choose_log.grid(row=1, column=2, sticky='w', padx=5) # Model rows label_model.grid(row=2, column=0) widgetholder.Widgets['models'].grid(row=2, column=1, sticky=['w', 'e', 'n', 's'], rowspan=3, pady=5) widgetholder.Widgets['model_desc'].grid(row=2, column=2, sticky=['w', 'e'], padx=5) widgetholder.Widgets['is_valid'].grid(row=3, column=2, sticky=['w', 'e']) widgetholder.Widgets['run_button'].grid(row=4, column=2, pady=5) # Column config [Not working?] inner_frame.grid(row=0, column=0, rowspan=5, columnspan=3, sticky=('N', 'S', 'E', 'W')) frame.columnconfigure(1, weight=4) frame.columnconfigure(2, weight=1) frame.rowconfigure(2, weight=1) frame.rowconfigure(3, weight=1) frame.rowconfigure(3, weight=1) # Populate list self.DirectoryChanged() return frame