def initUI(self):
        self.parent.title("Mario's Picross Puzzle Editor")
        self.puzzles = None

        # Build the menu
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        fileMenu = Menu(menubar)
        self.fileMenu = fileMenu
        fileMenu.add_command(label="Open Mario's Picross ROM...",
                              command=self.onOpen)
        fileMenu.add_command(label="Save ROM as...",
                             command=self.onSave,
                             state=DISABLED)
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=fileMenu)

        # Navigation
        Label(self.parent).grid(row=0, column=0)
        Label(self.parent).grid(row=0, column=4)
        self.parent.grid_columnconfigure(0, weight=1)
        self.parent.grid_columnconfigure(4, weight=1)

        prevButton = Button(self.parent,
                            text="<--",
                            command=self.onPrev,
                            state=DISABLED
        )
        self.prevButton = prevButton
        prevButton.grid(row=0, column=1)

        puzzle_number = 1
        self.puzzle_number = puzzle_number
        puzzleNumber = Label(self.parent, text="Puzzle #{}".format(puzzle_number))
        self.puzzleNumber = puzzleNumber
        puzzleNumber.grid(row=0, column=2)

        nextButton = Button(self.parent,
                            text="-->",
                            command=self.onNext,
                            state=DISABLED
        )
        self.nextButton = nextButton
        nextButton.grid(row=0, column=3)

        # Canvas
        canvas = Canvas(self.parent)
        self.canvas = canvas
        for i in range(15):
            for j in range(15):
                fillcolor = "gray80"
                self.canvas.create_rectangle(10+20*j,     10+20*i,
                                             10+20*(j+1), 10+20*(i+1),
                                             fill=fillcolor,
                                             tags="{},{}".format(i, j)
                )
        self.canvas.bind("<ButtonPress-1>", self.onClick)
        canvas.grid(row=1, columnspan=5, sticky=W+E+N+S)
        self.parent.grid_rowconfigure(1, weight=1)
    def createWidgets(self):    
        tabControl = ttk.Notebook(self.win)     
        tab1 = ttk.Frame(tabControl)            
        tabControl.add(tab1, text='Tab 1')    
        tabControl.pack(expand=1, fill="both")  
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        
        
        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')

        self.action = ttk.Button(self.monty, text="Click Me!")   
        self.action.grid(column=2, row=1)
        
        ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number)
        numberChosen['values'] = (42)
        numberChosen.grid(column=1, row=1)
        numberChosen.current(0)
   
        scrolW = 30; scrolH = 3
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)

        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        fileMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="File", menu=fileMenu)
        helpMenu = Menu(menuBar, tearoff=0)
        menuBar.add_cascade(label="Help", menu=helpMenu)

        nameEntered.focus()     
Ejemplo n.º 3
0
 def __init__(self, master=None):
     Frame.__init__(self, master)
     self.pack(expand=1, fill='both')
     self.master.geometry('1440x900')
     paned_window = PanedWindow(self)
     self.treeview_kspelements = TreeviewKSPElements(self)
     self.treeview_kspobjects = TreeviewKSPObjects(self)
     paned_window.pack(expand=1, fill='both')
     paned_window.add(self.treeview_kspelements)
     paned_window.add(self.treeview_kspobjects)
     
     menubar = Menu(self)
     
     filemenu = Menu(self)
     filemenu.add_command(label='Open', command=self._open)
     filemenu.add_command(label='Save', command=self._save)
     filemenu.add_command(label='Save As', command=self._save_as)
     filemenu.add_separator()
     filemenu.add_command(label='Exit', command=self.master.destroy)
     menubar.add_cascade(menu=filemenu, label='File')
     
     insertmenu = Menu(self)
     insertmenu.add_command(label='KSP Element', command=self._insert_element, state='disabled')
     insertmenu.add_command(label='KSP Object', command=self._insert_object)
     menubar.add_cascade(menu=insertmenu, label='Insert')
     self.master.config(menu=menubar)
Ejemplo n.º 4
0
    def initUI(self, server):
      
        self.parent.title("TrackWise Service Manager")
        self.pack(fill=BOTH, expand = True, padx = 300)
        # self.centerWindow()

        menubar = Menu(self.parent)
        self.parent.config(menu = menubar)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label = "Exit", command = self.onExit)
        menubar.add_cascade(label = "File", menu = fileMenu)

        svcsMenu = Menu(menubar)
        svcsMenu.add_command(label = "List Service Status", command = self.onStatus)
        svcsMenu.add_command(label = "Stop Services", command = self.onStop)
        svcsMenu.add_command(label = "Start Services", command = self.onStart)
        menubar.add_cascade(label = "Services", menu = svcsMenu)

        # svcs = ['TrackWise Tomcat', 'Web Services Tomcat', 'QMD Tomcat', 'Keystone Intake', 'ID Intake', 'TWC']
        svcs = server.getservices()
        hostname = server.gethostname().strip()
        servertype = server.gettype().strip()

        frame0 = Labelframe(self, text = "Server Details",  borderwidth = 1)
        frame0.grid(column = 0, row = 0, sticky = W)
        
        so = StringVar()
        svroverview = Message(frame0, textvariable = so, anchor = W, width = 300)
        svroverview.grid(column = 0, row = 0)
        sstr = "Server: {}\n".format(hostname)
        sstr += "Server Type: {}".format(servertype)
        so.set(sstr)
        
        
        frame1 = Labelframe(self, text = "Service Status", borderwidth = 1)
        frame1.grid(column = 0, row = 1, sticky = W)


        l = StringVar()
        label1 = Message(frame1, textvariable = l , anchor = W)
        
        svcscount = 0

        lstr = ""

        for i in svcs:
            svcscount += 1 
            lstr += '{} - '.format(i) + ('UP\n' if svcscount % 2 else 'DOWN\n')
      
            
        l.set(lstr)
        label1.pack(side=TOP, padx = 5, pady = 5)   

        frame4 = Frame(self, relief=RAISED, borderwidth = 1)
        frame4.grid(column = 0, row = 2, sticky = W)
        closeButton = Button(frame4, text="Close", command = self.quit)
        closeButton.grid(column = 0, row = 0)
        okButton = Button(frame4, text = "OK")
        okButton.grid(column = 1, row = 0)
Ejemplo n.º 5
0
 def BuildScriptMenu(self,parentmenu,modulename):
     from tkinter import Menu
     menu = Menu(parentmenu,bd=1,activeborderwidth=0)
     try:
         module = importlib.import_module('vmtk.'+modulename)
     except ImportError:
         return None
     scriptnames = [scriptname for scriptname in getattr(module, '__all__')]
     for index, scriptname in enumerate(scriptnames):
         # check if scriptname contains starting prefix 'vmtk.' and remove it before returning list to the user.
         if 'vmtk.' == scriptname[0:5]:
             splitList = scriptname.split('.')
             scriptnames[index] = splitList[1]
         else:
             continue
     menulength = 20
     for i in range(len(scriptnames)//menulength+1):
         subscriptnames = scriptnames[i*menulength:(i+1)*menulength]
         if not subscriptnames:
             break 
         submenu = Menu(menu,bd=1,activeborderwidth=0)
         menu.add_cascade(label=subscriptnames[0]+"...",menu=submenu)
         for scriptname in subscriptnames:
             callback = CallbackShim(self.InsertScriptName,scriptname)
             submenu.add_command(label=scriptname,command=callback)
     return menu 
Ejemplo n.º 6
0
    def init_menubar(self):
        """
        Creates the menubar. Called once on startup. The rendering
        of the menubar is operating-system dependent (Windows
        renders it inside the app window, OS X renders it in
        the OS menubar).
        """
        menubar = Menu(self.window)

        game_menu = Menu(menubar, tearoff=0)
        game_menu.add_command(
            label='New (Easy)',
            command=lambda: self.start_new_game('easy'))
        game_menu.add_command(
            label='New (Intermediate)',
            command=lambda: self.start_new_game('intermediate'))
        game_menu.add_command(
            label='New (Advanced)',
            command=lambda: self.start_new_game('advanced'))
        game_menu.add_command(
            label='New (Custom)',
            command=lambda: self.start_new_game('custom'))
        menubar.add_cascade(label='Game', menu=game_menu)

        # finally add the menubar to the root window
        self.window.config(menu=menubar)

        self.ui_elements += [menubar, game_menu]
Ejemplo n.º 7
0
    def initUI(self):
        self.parent.title('PyZilla')
        self.padding = 5

        self.pack(fill=BOTH, expand=1)

        # Create a menubar
        mnuMenu = Menu(self.parent)
        self.parent.config(menu=mnuMenu)

        # Create menubar
        mnuFileMenu = Menu(mnuMenu)

        # Add File menu items
        mnuFileMenu.add_command(label='Open', command=self.onBtnOpenFile)
        mnuFileMenu.add_command(label='Exit', command=self.quit)

        # Add File menu items to File menu
        mnuMenu.add_cascade(label='File', menu=mnuFileMenu)

        # Create frame for all the widgets
        frame = Frame(self)
        frame.pack(anchor=N, fill=BOTH)

        # Create file open dialog
        btnOpenFile = Button(frame, text="Load file", command=self.onBtnOpenFile)
        btnOpenFile.pack(side=RIGHT, pady=self.padding)

        # Create filename label
        self.lblFilename = Label(frame, text='No filename chosen...')
        self.lblFilename.pack(side=LEFT, pady=self.padding, padx=self.padding)

        # Create the text widget for the results
        self.txtResults = Text(self)
        self.txtResults.pack(fill=BOTH, expand=1, pady=self.padding, padx=self.padding)
    def _init_menubar(self, parent):
        menubar = Menu(parent)

        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="Exit", underline=1, command=self.destroy, accelerator="q")
        menubar.add_cascade(label="File", underline=0, menu=filemenu)

        actionmenu = Menu(menubar, tearoff=0)
        actionmenu.add_command(label="Next", underline=0, command=self.next, accelerator="n, Space")
        actionmenu.add_command(label="Previous", underline=0, command=self.prev, accelerator="p, Backspace")
        menubar.add_cascade(label="Action", underline=0, menu=actionmenu)

        optionmenu = Menu(menubar, tearoff=0)
        optionmenu.add_checkbutton(
            label="Remove Duplicates",
            underline=0,
            variable=self._glue.remove_duplicates,
            command=self._toggle_remove_duplicates,
            accelerator="r",
        )
        menubar.add_cascade(label="Options", underline=0, menu=optionmenu)

        viewmenu = Menu(menubar, tearoff=0)
        viewmenu.add_radiobutton(label="Tiny", variable=self._size, underline=0, value=10, command=self.resize)
        viewmenu.add_radiobutton(label="Small", variable=self._size, underline=0, value=12, command=self.resize)
        viewmenu.add_radiobutton(label="Medium", variable=self._size, underline=0, value=14, command=self.resize)
        viewmenu.add_radiobutton(label="Large", variable=self._size, underline=0, value=18, command=self.resize)
        viewmenu.add_radiobutton(label="Huge", variable=self._size, underline=0, value=24, command=self.resize)
        menubar.add_cascade(label="View", underline=0, menu=viewmenu)

        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="About", underline=0, command=self.about)
        menubar.add_cascade(label="Help", underline=0, menu=helpmenu)

        parent.config(menu=menubar)
    def __init__(self, parent, *args, **kwargs):
        tk.Frame.__init__(self, parent, *args, **kwargs)

        self.parent = parent
        self.parent.option_add('*tearOff', False)
        self.after(50, self.onAfter)

        #set this frame to expand to %100 available space
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        #init menu
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Save", command=self.onSave)
        fileMenu.add_command(label="Load", command=self.onLoad)
        fileMenu.add_command(label="Exit", command=self.onExit)
        menubar.add_cascade(label="File", menu=fileMenu)

        #init textbox
        self.text = ScrolledText(self, wrap='word')

        #add widgets to the layout manager
        self.text.grid(sticky=inflate)
Ejemplo n.º 10
0
Archivo: tree.py Proyecto: DrDub/nltk
    def _init_menubar(self):
        menubar = Menu(self._top)

        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label='Print to Postscript', underline=0,
                             command=self._cframe.print_to_file,
                             accelerator='Ctrl-p')
        filemenu.add_command(label='Exit', underline=1,
                             command=self.destroy, accelerator='Ctrl-x')
        menubar.add_cascade(label='File', underline=0, menu=filemenu)

        zoommenu = Menu(menubar, tearoff=0)
        zoommenu.add_radiobutton(label='Tiny', variable=self._size,
                                 underline=0, value=10, command=self.resize)
        zoommenu.add_radiobutton(label='Small', variable=self._size,
                                 underline=0, value=12, command=self.resize)
        zoommenu.add_radiobutton(label='Medium', variable=self._size,
                                 underline=0, value=14, command=self.resize)
        zoommenu.add_radiobutton(label='Large', variable=self._size,
                                 underline=0, value=28, command=self.resize)
        zoommenu.add_radiobutton(label='Huge', variable=self._size,
                                 underline=0, value=50, command=self.resize)
        menubar.add_cascade(label='Zoom', underline=0, menu=zoommenu)

        self._top.config(menu=menubar)
Ejemplo n.º 11
0
    def add_menus(self):
        menu_bar = Menu(self.root)
        stampede_menu = Menu(menu_bar, tearoff=0)
        stampede_menu.add_command(label="Settings", command=self.edit_default_settings)
        stampede_menu.add_separator()
        stampede_menu.add_command(label="Quit", command=self.root.quit)
        menu_bar.add_cascade(label="Stampede", menu=stampede_menu)

        self.root.config(menu=menu_bar)
Ejemplo n.º 12
0
	def modify_command(self, file_name):
		import tkinter as tk
		from tkinter import Menu
		from tkinter import messagebox
		import tkinter.scrolledtext as tkst
		import os.path
		if os.path.isfile(file_name):
			file = open(file_name, 'r')
			read_text = file.readlines()
			file_text = ''
			for line in read_text:
				file_text = file_text + line
			file.close()
		else:
			file_text = ''
		win = tk.Tk()
		win.title(file_name)
		frame1 = tk.Frame(
			master = win,
			bg = '#808000'
		)
		global editArea
		editArea = tkst.ScrolledText(
			master = frame1,
			wrap = tk.WORD,
			width = 20,
			height = 10
		)
		def save_command():
			global editArea
			file = open(file_name, 'w')
			data = editArea.get('1.0', 'end-1c')
			file.write(data)
			file.close()
		def not_save_exit_command():
			if messagebox.askokcancel("Quit", "(Not Save) Do you really want to quit?"):
				win.destroy()			
		def exit_command():
			global editArea
			file = open(file_name, 'w')
			data = editArea.get('1.0', 'end-1c')
			file.write(data)
			file.close()
			if messagebox.askokcancel("Quit", "Do you really want to quit?"):
				win.destroy()
		frame1.pack(fill='both', expand='yes')
		menu = Menu(win)
		win.config(menu=menu)
		filemenu = Menu(menu)
		menu.add_cascade(label='File', menu=filemenu)
		filemenu.add_command(label='Save', command=save_command)
		filemenu.add_command(label='Not Save and Exit', command=not_save_exit_command)
		filemenu.add_separator()
		filemenu.add_command(label='Save and Exit', command=exit_command)
		editArea.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)
		editArea.insert(tk.INSERT, file_text)
		win.mainloop()
Ejemplo n.º 13
0
 def __init__(self, parent, controller):
      tk.Frame.__init__(self, parent)
      menubar = Menu(self)
      filemenu = Menu(menubar,tearoff=0)
      filemenu.add_command(label="New",)
      filemenu.add_command(label="Open",)
      filemenu.add_command(label="Save As..")
      filemenu.add_command(label="Colour")
      filemenu.add_command(label="Close")
      menubar.add_cascade(label="File",menu=filemenu)
      controller.configure(menu = menubar)
Ejemplo n.º 14
0
	def initUI(self):
		self.parent.title("Gas Model")
		self.fonts = {'fontname'   : 'Helvetica',
		    'color'      : 'r',
		    'fontweight' : 'bold',
		    'fontsize'   : 14}
		self.npts = 32;
		self.sounds = 377.9683;
		self.skip = 4000.
#		self.dt = 5000.*self.skip/(self.npts * self.sounds)

		menubar = Menu(self.parent)
		menubar.config(font=("Helvetica", 14, "italic"))
		self.parent.config(menu=menubar)

		fileMenu = Menu(menubar, tearoff=0)
		fileMenu.config(font=("Helvetica", 14, "italic"))
		fileMenu.add_command(label="Load", command=self.onLoad)
		fileMenu.add_command(label="Close", command=self.onClose)
		fileMenu.add_command(label="Exit", command=self.quit)
		menubar.add_cascade(label="File", menu=fileMenu)
		
		fileMenu2 = Menu(menubar, tearoff=0)
		fileMenu2.config(font=("Helvetica", 14, "italic"))
		fileMenu2.add_command(label="Set Parameters", command=self.quit)
		menubar.add_cascade(label="Parameters", menu=fileMenu2)
		lbl1=Label(self.parent,text="Gas Network",fg = "black",font=("Helvetica", 14, "bold"))
		lbl1.grid(sticky="N",pady=4,padx=5,row=0,column=0,columnspan=2)

		self.f = plt.figure(figsize=(5,4), dpi=80)
		self.cmap = plt.cm.jet #ok
		self.a = self.f.add_subplot(111)
		self.a.axis([-1, 1, -1, 1])
		self.a.axis('off')

		self.canvas = FigureCanvasTkAgg(self.f, master=self.parent)
		self.G = nx.Graph()
		nx.draw_networkx(self.G, pos=nx.spring_layout(self.G), ax=self.a)
		self.canvas.show()
		self.canvas.get_tk_widget().config(width=800-20, height=600-100)
		self.canvas.get_tk_widget().grid(sticky="NW", pady=4, padx=5, row=1, column=0, columnspan=6, rowspan=6) 
		self.txt = Text(self.parent, width=54, height=33);
		self.txt.grid(sticky="NW", pady=4, padx=5, row=1, column=8, columnspan=4, rowspan=6)	

		self.log = Text(self.parent, width=112, height=6);
		self.log.grid(sticky="NW", pady=4, padx=5, row=7, column=0, columnspan=6,rowspan=2)

		RunButton = Button(self.parent, text="Run", width=10, command=self.onRun).grid(sticky='SW', pady=4, padx=5, row=7, column=8)
		DrawButton = Button(self.parent, text="Draw", width=10, command=self.onDraw).grid(sticky='SW', pady=4, padx=5, row=7, column=9)
		StopButton = Button(self.parent, text="Stop", width=10, command=self.onStop).grid(sticky='SW', pady=4, padx=5, row=8, column=9)
		QuitButton = Button(self.parent, text="Quit", width=10, command=self.quit ).grid(sticky='SW', pady=4, padx=5, row=7, column=10)
		self.Loaded = False
		self.Animate = False
Ejemplo n.º 15
0
    def __init__(self, tk: Tk):
        tk.title("Layered Polygons")

        menubar = Menu(tk)

        menu_file = Menu(menubar, tearoff=0)
        menu_file.add_command(label="New...", command=self._new_scene)
        menu_file.add_command(label="Open...", command=self._open_scene)
        menu_file.add_separator()
        menu_file.add_command(label="Save", command=self._save_scene)
        menu_file.add_command(label="Save As...", command=self._save_scene_as)
        menu_file.add_separator()
        menu_export = Menu(menu_file, tearoff=0)
        menu_export.add_command(label="Wavefront (.obj)...",
                                command=self._export_obj)
        menu_file.add_cascade(label="Export As", menu=menu_export)
        menu_file.add_separator()
        menu_file.add_command(label="Quit", command=self._quit_app)
        menubar.add_cascade(label="File", menu=menu_file)

        tk.config(menu=menubar)

        paned = PanedWindow(tk, relief=RAISED)
        paned.pack(fill=BOTH, expand=1)

        frame = Frame(paned)
        paned.add(frame)
        self._canvas = LayPolyCanvas(frame)
        bar_x = Scrollbar(frame, orient=HORIZONTAL)
        bar_x.pack(side=BOTTOM, fill=X)
        bar_x.config(command=self._canvas.xview)
        bar_y = Scrollbar(frame, orient=VERTICAL)
        bar_y.pack(side=RIGHT, fill=Y)
        bar_y.config(command=self._canvas.yview)
        self._canvas.config(xscrollcommand=bar_x.set, yscrollcommand=bar_y.set)
        self._canvas.pack(side=LEFT, expand=True, fill=BOTH)
        # Thanks to the two guys on Stack Overflow for that!
        # ( http://stackoverflow.com/a/7734187 )

        self._layer_list = Listbox(paned, selectmode=SINGLE)
        paned.add(self._layer_list)

        self._scene = None
        self._current_layer = None
        self._is_drawing_polygon = False
        self._tk = tk

        self._canvas.bind("<Button-1>", self._canvas_left_click)
        self._canvas.bind("<Button-3>", self._canvas_right_click)
        self._canvas.bind("<Motion>", self._canvas_mouse_moved)
        self._layer_list.bind("<<ListboxSelect>>", self._layer_change)

        self._current_path = None
Ejemplo n.º 16
0
    def init_menu_bar(self):
        """Creating MenuBar : File, Connect, Help"""
        menu_bar = Menu(self)

        menu_file = Menu(menu_bar, tearoff=0)
        menu_file.add_command(label="Quit", command=self._quit)
        menu_bar.add_cascade(label="File", menu=menu_file)

        menu_connect = Menu(menu_bar, tearoff=0)
        menu_connect.add_command(label="Host", command=self.host_window)
        menu_connect.add_command(label="Connect", command=self.connect_window)
        menu_bar.add_cascade(label="Connect", menu=menu_connect)

        menu_character_sheet = Menu(menu_bar, tearoff=0)
        menu_character_sheet.add_command(label="Save As...", command=self.tab_character_sheet.save)
        menu_character_sheet.add_command(label="Load", command=self.tab_character_sheet.load)
        menu_character_sheet.add_command(label="Reset", command=self.tab_character_sheet.reset)
        menu_character_sheet.add_command(label="Roll Characteristics", \
                                        command=self.tab_character_sheet.rollCharacteristics)
        menu_character_sheet.add_checkbutton(label="Freeze Characteristics", \
                                        variable=self.tab_character_sheet.freeze)
        menu_bar.add_cascade(label="Character Sheet", menu=menu_character_sheet)        
        
        menu_help = Menu(menu_bar, tearoff=0)
        menu_help.add_command(label="About", command=self.about)
        menu_bar.add_cascade(label="Help", menu=menu_help)

        self.window.config(menu=menu_bar)
    def initUI(self):

        self.parent.title("File dialog")
        self.pack(fill=BOTH, expand=1)

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Open", command=self.onOpen)
        menubar.add_cascade(label="File", menu=fileMenu)

        self.txt = Text(self)
        self.txt.pack(fill=BOTH, expand=1)
Ejemplo n.º 18
0
    def _place_menu_cascade(menubar: tk.Menu, menu_name: str,
                            postcommand: Callable,
                            menu_items: Sequence[Union[MenuItem, str]],
                            menu_label: str, item_labels: Sequence[str], ):
        """Create a menu with its menu items.

        Args:
            menubar: Parent menu bar.
            menu_name: Internal name of menu
            postcommand: Called when the user clicks on the menubar. NB: If three menus have
                postcommand functions then all three will be called every time the user
                clicks on the menubar. Postcommand function calls are not restricted to one
                peculiar to the drop down menu being viewed by the user.
            menu_items: Handler, initial active state, observer
            menu_label: User visible menu name
            item_labels:User visible menu item name
        """
        only_menu_items = [menu_item for menu_item in menu_items
                           if not isinstance(menu_item, str)]
        if len(only_menu_items) != len(item_labels):
            msg = ("There should be {} items for '{}' in config.ini."
                   "".format(len(only_menu_items), menu_name))
            logging.error(msg=msg)
            raise ValueError(msg)
        cascade = tk.Menu(menubar)
        if postcommand:
            cascade.config(postcommand=lambda: postcommand(cascade))
        item_label = iter(item_labels)
        for ix, menu_item in enumerate(menu_items):
            if isinstance(menu_item, str):
                cascade.add_separator()
            elif callable(menu_item.handler):
                label = next(item_label)
                handler = menu_item.handler
                if menu_item.active:
                    cascade.add_command(label=label, command=handler, state=tk.ACTIVE)
                else:
                    cascade.add_command(label=label, command=handler, state=tk.DISABLED)
                if menu_item.observable:
                    observer = partial(guisupport.menu_item_enable_observer, cascade, ix)
                    menu_item.observable.register(observer)
            elif not menu_item.handler:
                cascade.add_command(label=next(item_label), state=tk.DISABLED)
            else:
                label = next(item_label)
                msg = ("The menu item '{}' is not a separator and does not contain a handler."
                       "".format(label))
                logging.error(msg=msg)
                cascade.add_command(label=label, state=tk.DISABLED)
        menubar.add_cascade(label=menu_label, menu=cascade)
Ejemplo n.º 19
0
    def __init__(self, master, version):
        Frame.__init__(self, master)
        master.title(version[:-5])
        # MAKE IT LOOK GOOD
        style = Style()
        style.configure("atitle.TLabel", font="tkDefaultFont 12 bold italic")

        # CREATE AND SET VARIABLES
        self.version = version
        self.description = None
        self.logo = None
        self.status_lbl = StringVar()  # TO HOLD STATUS VARIABLE IN STATUSBAR

        # CREATE ROOT MENUBAR
        menubar = Menu(self.master)
        self.master["menu"] = menubar
        self.master.option_add("*tearOff", False)
        # CREATE FILE MENU
        self.menu_file = Menu(menubar, name="file")
        self.menu_file.add_separator()
        self.menu_file.add_command(label="Exit", accelerator="Alt-F4", command=self.master.destroy)
        menubar.add_cascade(menu=self.menu_file, label="File", underline=0)
        # CREATE HELP MENU
        menu_help = Menu(menubar, name="help")
        menu_help.add_command(label="About", command=self.show_about)
        menubar.add_cascade(menu=menu_help, label="Help", underline=0)

        # CREATE BUTTON BAR
        self.button_bar = Frame(self.master, relief="groove", padding="0 1 0 2")
        self.button_bar.grid(sticky="ew")

        # SETUP PRIMARY FRAME FOR WIDGETS
        self.frame = Frame(self.master, padding="25")
        self.frame.grid(sticky="nsew")

        # CREATE STATUS BAR
        Separator(self.master).grid(row=8, sticky="ew")
        self.status_bar = Frame(self.master, padding="8 0 0 1")
        self.status_bar.grid(row=9, sticky="ews")
        Label(self.status_bar, textvariable=self.status_lbl).grid(row=0, column=0, padx="0 7")
        Label(self.status_bar, text=self.version[-5:]).grid(row=0, column=8)
        Sizegrip(self.status_bar).grid(row=0, column=9, sticky="e")

        # CONFIGURE AUTO-RESIZING
        self.master.columnconfigure(0, weight=1)
        self.master.rowconfigure(1, weight=1)
        self.frame.columnconfigure(0, weight=1)
        # self.frame.rowconfigure(0, weight=1)
        self.status_bar.columnconfigure(1, weight=1)
Ejemplo n.º 20
0
    def _createMenu(self):
        """ Create the menu """

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        # File Menu
        mnuFile = Menu(menubar)
        mnuFile.add_command(label="Exit", underline=1, command=self._onMenuFileExit)
        menubar.add_cascade(label="File", underline=0, menu=mnuFile)

        # Help Menu
        mnuHelp = Menu(menubar)
        mnuHelp.add_command(label="About", underline=0, command=self._onMenuHelpAbout)
        menubar.add_cascade(label="Help", underline=0, menu=mnuHelp)
Ejemplo n.º 21
0
    def make_menu(self):
        menu = Menu(self)

        file_menu = Menu(menu, tearoff=0)
        file_menu.add_command(label='Exit', command=self.ask_for_quiting)

        help_menu = Menu(menu, tearoff=0)
        help_menu.add_command(label='About',
                              command=lambda: messagebox.showinfo('Calendar',
                                                                  'By Fedor'))

        menu.add_cascade(label='File', menu=file_menu)
        menu.add_cascade(label='Help', menu=help_menu)

        return menu
Ejemplo n.º 22
0
 def initUI(self):
     self.parent.title("Vagas Generator")
     self.pack(fill=BOTH, expand=1)
     menubar = Menu(self.parent)
     self.parent.config(menu=menubar)
     fileMenu = Menu(menubar,tearoff=0)
     fileMenu.add_command(label="Abrir", command=self.onOpen)
     fileMenu.add_command(label="Salvar", command=self.onSave)
     ajuda = Menu(menubar,tearoff=0)
     ajuda.add_command(label="Como usar", command=self.uso)
     ajuda.add_command(label="Sobre", command=self.sobre)
     menubar.add_cascade(label="Arquivo", menu=fileMenu)
     menubar.add_cascade(label="Ajuda",menu=ajuda)
     self.txt = Text(self)
     self.txt.pack(fill=BOTH, expand=1)
def main():
    '''Makes the application
    '''
    root = Tk()
    app = Application(master=root)
    app.master.title("Password Generator")
    root.minsize(500, 500)
    root.maxsize(600, 600)

    menubar = Menu(root)
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Exit", command=root.destroy)
    menubar.add_cascade(label="File", menu=filemenu)
    root.config(bg='#2A2C2B', menu=menubar)
    app.mainloop()
Ejemplo n.º 24
0
    def __init__(self):
        super().__init__()
        self.title('Hangman')
        self.geometry('640x480+200+200')
        self.resizable(width=False, height=False)

        menu_bar = Menu(self, tearoff=0)
        self.config(menu=menu_bar)

        game_menu = Menu(menu_bar, tearoff=0)
        game_menu.add_command(label='New game', command=self.__on_new_game)
        game_menu.add_command(label='Quit', command=self.__on_quit)
        menu_bar.add_cascade(label='Game', menu=game_menu)

        self.__hang_canvas = Canvas(self, background='#ffffff')
        self.__hang_canvas.pack(fill=BOTH, expand=True)

        self.__dict_filename = os.path.join(os.path.dirname(__file__), 'dictionary.txt')
        self.__dictionary = []
        self.__secret_word_masked = StringVar()
        self.__game_stages = (
            # (is_circle, x1, y1, x2, y2),
            (False, 50, 300, 200, 300), # podstawa
            (False, 60, 300, 60, 10), # maszt
            (False, 60, 10, 160, 10),
            (False, 60, 30, 100, 10),
            (False, 160, 10, 160, 30),
            (True, 140, 30, 180, 70),
            (False, 160, 70, 160, 200), # tułów
            (False, 140, 120, 160, 70), # lewa reka
            (False, 180, 120, 160, 70), # prawa ręka
            (False, 160, 200, 140, 250),
            (False, 160, 200, 180, 250)
        )
        self.__errors_count = 0

        secret_word_label = Label(self, font=('purisa', 36), textvariable=self.__secret_word_masked)
        secret_word_label.pack(fill=X)

        # user input panel
        Label(self, text='Please input a char:').pack(fill=X)
        self.__user_input_char = StringVar()
        user_input_entry = Entry(self, textvariable=self.__user_input_char)
        user_input_entry.bind('<Return>', self.__on_user_input)
        user_input_entry.pack()

        self.__load_dictionary()
        self.__new_game()
Ejemplo n.º 25
0
class MyGUI(Frame):

	def __init__(self, parent=None):
		Frame.__init__(self,parent)
		self.parent = parent
		self.parent.title("Accounting")
		
		self.status = StatusBar(parent)
		self.status.set("%s","...")
		self.status.pack(side=BOTTOM, fill=BOTH)
		
		self.leftmenu = LeftMenu(parent)
		self.leftmenu.pack(side=LEFT, fill=BOTH)
			
		self.paymentframe = Frame(self,relief=GROOVE, bd=1)
		Label(self.paymentframe,text="Упорядочить по",height=2).grid(row=0,column=0,columnspan=2)
		self.paymentframe.pack(side=TOP,fill=BOTH,expand=YES)

		
		self.menubar = Menu(self)
		menu = Menu(self.menubar, tearoff=0)
		self.menubar.add_cascade(label="File", menu=menu)
		menu.add_command(label="LogIn", command=(lambda: authWindow(self)))
		menu.add_separator()
		menu.add_command(label="MessBox",command=(lambda: self.addPayment()))
		menu.add_separator()
		menu.add_command(label="Close", command=self.quit)

		menu = Menu(self.menubar, tearoff=0)
		self.menubar.add_cascade(label="Other", menu=menu)
		menu.add_command(label="Статистика", command=(lambda: Statistics(self)))
		menu.add_command(label="Copy")
		menu.add_command(label="Paste")
		
		try:
			self.master.config(menu=self.menubar)
		except AttributeError:
		    # master is a toplevel window (Python 1.4/Tkinter 1.63)
		    self.master.tk.call(master, "config", "-menu", self.menubar)		
		
		
		self.pack()
	
	def addPayment(self):
		pass
		
	def reply(self,text):
		messagebox.showinfo(title='popup', message=user.name)
Ejemplo n.º 26
0
    def __init__(self, root, config_save):
        self.root = root
        self.config_save = config_save

        # Create a menu
        root_menu = Menu(root)
        root.config(menu=root_menu)

        xnat_menu = Menu(root_menu)
        root_menu.add_cascade(label="GIFT-Cloud", menu=xnat_menu)

        xnat_menu.add_command(label="About", command=self.menu_about)
        xnat_menu.add_separator()
        xnat_menu.add_command(label="Settings", command=self.menu_settings)
        xnat_menu.add_separator()
        xnat_menu.add_command(label="Quit", command=self.menu_exit)
Ejemplo n.º 27
0
    def _initUI(self):
        self.parent.title("Pydle v" + self.version)
        self.parent.minsize(width=str(self.screenWidth), height=str(self.screenHeight))
        # self.parent.config(border=0)

        # Styles
        style = Style()
        style.configure("TFrame", background="gray", border=0)
        style.configure("TButton", background="gray", foreground="lightgray", highlightforeground="black", highlightbackground="darkgray", compound=RIGHT, relief=FLAT)

        self.config(style="TFrame")
        self.pack(fill=BOTH, expand=1)

        # Menus
        mnuBar = Menu(self.parent)
        self.parent.config(menu=mnuBar)

        mnuFile = Menu(mnuBar, background="gray")
        mnuFile.add_command(label="Exit", command=self.onExitMnu)
        mnuBar.add_cascade(label="File", menu=mnuFile)

        mnuHelp = Menu(mnuBar, background="gray")
        mnuHelp.add_command(label="About", command=self.onAboutMnu)
        mnuBar.add_cascade(label="Help", menu=mnuHelp)

        # Frame content
        frmBooks = Frame(self, style="TFrame")
        frmBooks.pack(side=LEFT, anchor=N+W, fill=BOTH, expand=1, padx=(self.padding, self.padding / 2), pady=self.padding)

        self.lstBooks = Listbox(frmBooks)
        self.lstBooks.config(background="lightgray", foreground="black", borderwidth=0)
        self.lstBooks.pack(fill=BOTH, expand=1)

        frmButtons = Frame(self)
        frmButtons.pack(anchor=N+E, padx=(self.padding / 2, self.padding), pady=self.padding)

        btnLoadBooks = Button(frmButtons, text="Load Books", style="TButton", command=self.onLoadBooksBtn)
        btnLoadBooks.pack(side=TOP, fill=X)

        btnGetNotes = Button(frmButtons, text="Get Notes", style="TButton", command=self.onGetNotesBtn)
        btnGetNotes.pack(side=TOP, fill=X)

        btnBackupBook = Button(frmButtons, text="Backup Book", style="TButton", command=self.onBackupBtn)
        btnBackupBook.pack(side=TOP, fill=X)

        btnBackupAllBooks = Button(frmButtons, text="Backup All Books", style="TButton", command=self.onBackupAllBtn)
        btnBackupAllBooks.pack(side=TOP, fill=X)
Ejemplo n.º 28
0
    def __init__(self, master, version):
        Frame.__init__(self, master, padding='8 8 8 1')
        master.title(version[:-5])

        # CREATE AND SET VARIABLES
        self.version = version
        self.description = None
        self.logo = None
        self.status_lbl = StringVar()

        # CREATE ROOT MENUBAR
        menubar = Menu(self.master)
        self.master['menu'] = menubar
        self.master.option_add('*tearOff', False)
        # CREATE FILE MENU
        self.menu_file = Menu(menubar, name='file')
        self.menu_file.add_separator()
        self.menu_file.add_command(label='Exit', accelerator='Alt-F4', command=self.master.destroy)
        menubar.add_cascade(menu=self.menu_file, label='File', underline=0)
        # CREATE HELP MENU
        menu_help = Menu(menubar, name='help')
        menu_help.add_command(label='About', command=self.show_about)
        menubar.add_cascade(menu=menu_help, label='Help', underline=0)

        # CREATE BUTTON BAR
        self.button_bar = Frame(self.master, relief='groove', padding='0 1 0 2')
        self.button_bar.grid(sticky='ew')
        
        # SETUP PRIMARY FRAME FOR WIDGETS
        self.frame = Frame(self.master, padding='8')
        self.frame.grid(sticky='nsew')

        # CREATE STATUS BAR
        Separator(self.master).grid(row=8, sticky='ew')
        self.status_bar = Frame(self.master, padding='8 0 0 1')
        self.status_bar.grid(row=9, sticky='ews')
        Label(self.status_bar, textvariable=self.status_lbl).grid(row=0, column=0)
        Label(self.status_bar, text=self.version[-5:]).grid(row=0, column=8)
        Sizegrip(self.status_bar).grid(row=0, column=9, sticky='e')
        
        # CONFIGURE AUTO-RESIZING
        self.master.columnconfigure(0, weight=1)
        self.master.rowconfigure(1, weight=1)
        self.frame.columnconfigure(0, weight=1)
        self.frame.rowconfigure(0, weight=1)
        self.status_bar.columnconfigure(1, weight=1)
Ejemplo n.º 29
0
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         


        if not os.path.exists(self.WORK_FILE):
            os.makedirs(self.WORK_DIR)
            self.simulateReboot(True)




        self.parent = parent

        menu = Menu(self.parent)
        menu1 = Menu(menu,tearoff=0)
        menu1.add_command(label="Simulate Reboot",command=self.simulateReboot)
        menu1.add_separator()
        menu1.add_command(label="Quit!", command=self.parent.quit)
        menu.add_cascade(label="Menu",menu=menu1)

        # display the menu
        self.parent.config(menu=menu)

        self.parent.title("GPIOSim")        
        self.pack(fill=BOTH, expand=1)

        self.canvas = None
        self.canvas = Canvas(self, bg=self.BG_COLOR) 
        #self.canvas.bind("<Button-1>",self.click)


        #Images (gif base64 encoded)
        imgInLeft = "R0lGODlhHgASAOf7AAoMCAITBBcQCAYbAAsaEBUYEBEaCRMeCB0ZIREhGRkhFB0gEyMmGiIpFy8mNTQyNiROCCJZACxYCTlUKzpWGyleADBeBjRdGCxiCShlAEFcM0BeKDJmAzpmBCFwADxlIBt1BC9yBGpZW0NpMTtvDzttKkdqPid8AENxHD12DDh5AE9tPEZyJUV2Lzh/AF5rYD5+CEV+Fz+AGFxzT1h4LUx9NUaEAkCGA2dxYUqCEF91V1V8ME+AG0WHADuKCFl/RU+IIT2PG2l8XkqPAEuMJFmFREWTBVCRDzGcAHl6g2yBaEuWADybAEKZDkaaAHCHYnaCgneEeFCcA2WPR0ChB1qaA1ebFnuIbk2gCkSlAFCiAFegAF6fAFehD3ORXmueEXOWT26aQU+qBnCZV1inF3yUboCRhWWmBlmqCnuYa2OqAGGqDGOnJVevAF6tAEi0AG2sAF2vIYyXhomado2Ze1S2BmOyBHKpO1e3AGqxBVy1B1q0GXKwAG6sNEm9AH2tB3WrNYmfc22zAHumX2K4AH+maWO0NW61D2m4En60AHK4AGy6AHm3AIW0AHW2IYKsYoSrbnuzPW22S2u7JXS3NpKzBmDAG5CyGW66OI2ph3G7MIuyP4mteou5AHu/AIOzYXa7QpSpnKajqHu8M4O/AIG+EZy4AHe/K4m+AJytdZW8AIO4XnDCNp+ug429KaGrppG4YX+8dHzDUZnAHZ3CAJ/AJo7FK5O+c5+7cp7CP5jKJ5bIQpvAhqi8ia+6lYfLZ5PPHZrFbKHNDK/HVqnJcqHRPqDSTLvDq7TTN7jGubTLnMbRO8DTQ8TGw7DSjb/UVLDSmMTTZ7rYXbjWeMvVVNPSX8jZQbnfOMjYYcfbU7Xeb9XaTs/abt7XcMLjUMXhe8fficvbwdzV4czncNnb2NThwcnkztXlt+nr6OXy2Ozx9PLx6OP34vnv9e306fzx/vP35vL3+ff2/v/3/fj69//58v/76//6+PH/8/L///799P78//j/9Pb/+vn+//3//CH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAHgASAAAI/gCJATpFKRIrTM5+YYpEadIoUNBkadLUJ5KhVfDe9cO3b58/doaodEGj5gwaYneQiDmzxgqmW0yy7LHjpgsmd/9y/rs37xwbNdeWIePSB1cXRtuY6VqyKlgVRtaWAXMSC96+fvb0+ZvnDMsfatmKSZF0a4iibNlqMRkEy4grsJua8Lq37x8/fzl5GXE0TtouJJA4IbHV7RmiJp8+MSlWzZuiI8o6/qs7790gJ666YbPVoxeYIbnGRUOUI1WYL7OE0UJDJNy+e/T2xe4HZMkwbtwsgYBGhIyxarXcBOEEBI0qU6SWhEnXzh8/ffvipduBZRq4b2tI+OKxJZEqT06m/hS6kQdVpUQ9xtDj19Gev33lUMTRFm2WlhqZYsAh1anRkDFp3IDHcYec8Mhk/8ADnTkpYHHJJYs4QUMgMnDRCCqL2OCFFzeo0UgnioQwh0f+6KOPOiMYIQiIYnDQCgtPNaJIE0WUQQIXiZRyiAtTrHOPP/nc888KMORBiiB2VBCKCUPkwYgnW5RgRgld8JFIHka0EE49WnWkRAiI5AEHGhnQoYMKbthxiBYdXPGDD3YgWQULydRFD3SvYIAGIWq4oYIQV2QQJx56cIBDGR4sogYhaJAgR0d40XOMBF3ogYYdPawQhQRouKGGHiHoYEYEe7iRRxsWPDFZR/uIs8EQY2KssYYTGkBxgRRdtFFHCjMkAUEbbVzqwQsK5nSPPBvAUMcbeFgRwQsfDFEHHnbkQAEOt77hRxspTICOTjmJIMACCSRgQAEPOAAAAQQEMMABDCAwbgEKHNCAKM2QQw469PwTEAA7"
        imgInRight = "R0lGODlhHgASAOf8ABcOChASDwkZDg8YBxcZCw8dDicUJhcdABkfCxgmBBApABwnDi4kLCsnJjJHICNUBCZUACxdBC5fAD5XKTFgEiRmATZeLUVcOTpiJDhnGStuADZrDzxpFEZlLjVvATxuASl0ADpyAEhpODtzGUxrQEpwHUlwJDp6AVFsXlVwLUp0Ll9rXTaACF5uSzOEADuCAFpzTFJ5LWprdEx+HEWEEkiGBVh3bkaGEzWNADyMClh/PD+NAEeMAESKJjiSEk2MG2GAWVGMLTmYAFqJOkOXAFmKQXCBXUqWAHd8fkmWC22EX1KWDk+aAE2aE0edFUqeBHuEf3iJfEmkAFCiAF6dE1ihAF+gAHmQXkynAGeaPEWqAn2OfHWSbmKfOH+Sc16nBViqCU2vAFCsG4STe2KqAGeoC1SuD2KnLnedVYCXfWynHF6uAFiwAHCpEIaXhWeuAHOrAHmhUmOtII6YdVS1BWavFVa2AIOea2mqQoGgZnCvBGSzB3mvAH+uAGyzC1O8AGuwOG+1AGm3AHGyKGS6AIOyAHm2AG26AHuwOo2jiWm2PHS6Ani3FXa1NYKsa3a3I4G4BX+3GJmjkm65N421BpCpeW69GnG6MIGxX3O7Jma/KJS1C3q+AHm4SG7DAIq7AI63I5W3IHO/QYS2aoO+IZW8AIG6Une9YH3DFnjCN4+6W6CvlpqxlqC/AJvBAJC7ZpbDDYvHDpK8cZe4jpq7a6DBIJ26dbK+JIvIN4vJLpzELprEN4jGd57EUbW4lZbGc6bJPpzIaJnJdpzLXaPMQL7KMqjJjJHVcKvOl7zIsLbNnrfUWsrOYbLQoMXWNMbUTsbVV8vWQNDTVLbZc7/aUcXaQdXOjbnfOMrMycHaWbfeaL/hZcfkNsffbdPfUd/bcMHld9XW4NnjdN/c4dHjxdzfz8ztf+Di38vvtvXm9enr6Oby3/Py6ev26vzz7Or63/b0+Pb2//f61e/76Pb49P/1++77/Pb7/vn/4Pf+8/X/+v/8+/78///+9fn///3/+yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAHgASAAAI/gD55fvH7969d50aTRp0yZKqZqIUZboE6FEwZJoUNWI46Vi/ffTu8ZOH6AmZOmDCOOGVSooaPV+0nPklpswaMmuedMGXr94/ffReHcnF7VkkJrRMVanlrNqiJsLOkCkW7VqZM+j+iYTXz1aOTNCi7eLxStURXNKqRUoiCw8WYNCktWnSbF8/fvT+KUvyaJs3YEJOYSJiiVo2UDgcYRKyC9o2Rkl43fP5k9yPKaVuwaKSZRSNMt3EEWuCxlYNUsy+4eIRJx+/ePfcvQvCJFarUmSCVPoBRhe0YVR6GHNRxxy4XkSKzOMHTx/zPDkMtfq0h8adLkcguaJkxYcvD3LA/lmbhmXGun/7/vX754iFn1Kl9rC4gmbHok2G1syoFAMLqmXa1PEBOesZxM8/c4DgSR+UrPECF1fwQEghlIDBQiIlMHFIKKA8McI5BxJ0YDpDuMBIH5xUMYIXOjwRCCWLPGHCLBJ8YUghhyTRgT30fESPa+WYsMQhehjChAppYPAFJ3r4sQMJrECwhiF8vHEECT3x048++eyTzAZMvBGIIDXoEEUGUwQCByEhAJHGB3vooUcYHijBj5b6/KOVGxx8cZMfGnixggdrBLLGGhVsscIJYfjhBxgcSJKXSAYascEea4BhhgRjwEDoGmyAEUEUIuQAxhtsNEFBMiL1E5I+ZOy0UAEddIBBxgNIwPBCSnUcEQEUFzTBxrA1TBDOnXqKxI4DKbBhBx1rPGCDBTXQEQYdS1iAAgRVhPEHGyxg0M6B6owTDjarKJBAAQIgAIABDBwwALsEAMBAAwsQcEACCwQgQ0AAOw=="

        imgOutLeft = "R0lGODlhHgASAOf7AAgiSgYlPA8nNQYrLRUnOhovUxwwRB0yNgA2eiIzPyoxQgA2jh46TR85Wik9Vz44TBM/jARElgdEnSI/gRFEihhEfipBcgBIrQBLpBBFtwBOmhZLkSlJeQBSnABUpQBWrghTxABWwyNPpCBTjRZXlxpWowdZvxRXtABetyVYjBdWzxdbpABgvwBd4ABd5wBg2wRjyhpevwRj0BpexSlawxtc2TFbpBtd0wBk5TFdnwplxQxk2QBn4ThfjxNk6ABtzABs2QBr5gBq9BNrtABr7RhozwFt4jlloU5kdB1o3kllhQpv3QBy3i9rnABz2QBy5Uxjohdwww5x2A9v6wB3zwB070NqjgF5xAB26gB34zRtrgB50QB1/wB74R504wZ76DBv7mVpjwB+6gp77yF16k1vp0NwwQB+/wCC7jx0ygCC9kd2pmJwoCt9w092og6D6lp2lx5/9R6A71N2tgSJ6CB//AiG/z961BaH4E940Fl6oACL/j994COH2j2Bz06AqiaG5gCQ9QCS4xiK+DOG0zaE30CA7gCS/1GBxW5/kwGW9R+O9R+P71GD222BpV6GoAeY8GaFmkmKvzOM7TKP4mCLsACh+TGV4Red74CGqVSQzUiT1TGX+EuS3nyLqlqS1nqOshOn6zOe6nCTqGGUzGWVwSel8EOe5XCVvGiV23GWt0yb/3OWy3WW4kqj62+frHyZyG+e3oaduiiz/nGj0o+bzoKe4Tiz8Uqt+3ai6UWx6mOq+6ehrGGx7IGp5DS+/Ea5/5Wo7pSsyl656kO//zrG4j/F6H2z5V27/DzG/VTB85uyw4G411HH/5a52KW5uH7A/2nN81HV/6jA0nTL/2fQ/2PU+X7P8ZjO4JTN+bzL36fQ7LjL8rDQ4MfNz9HUxNvX0sfj7tLo+N7m7+Tp7OTw5/Px9fL08dr7/vj07Pzy+fv14O73//H3+fr18+P+6P/19u387//2/Pj69/X88fD9/u3/+P/92v/6+fT++f/87f77//j9//j/7v7+9Pz/+yH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAHgASAAAI/gDzpcM375+8d50GFbpD6dKmbX4MTWrDCE+uYIAA+QFEiRCzfPz87Ztnr1GRJ3WY8MDhyxARI1Kk4ACTa4oUKmdcvODD7hzIf/VouViU7NelGL0+oRCVjBidFrTaOPllbNaYNOL2/RPZz5mKQrqamTLRatOLU9KKyTFxLE+UW8qIXYnC7V7Ifeu6oYjTzBouE6lKgcA0TJooFbbm4MDUDFmdFs7a+VNXz1y5E0AghcKEIw8pHV+oVVsVQlOpF5eiUbsUopW+fPH08UOn5cUgS5CMFIE1REgoV8BmmImlow+0a51gSDo3st6+dH92iBmkKIsJVHNuLFKkCIgWWTGu/mTDtquFlnL89vXTSurEmEGHvnhQhSjEF0GQiNBANeQHp2HIZNGEOPKEhI859QizwBd0MDJGDGvAkkEdgtAxxQeVlFHDFm/Y8cMK4cDzDz3/8NOOOqx4sEUgYwBRghuasCBGF3ssUUItIkhhxxNo6NCEOfT4ww8/BrFjhQdYoPEFFiuM0sMOdnThxQ45vOIBEHiokUUISuTDXD5C+jPOESZ4oUYVMNiQyQZGvEGFGhc8kogEWXxRxRga6KHVOf/Y484+2pAAAxlfZAECFJ5Q8IQaTnCRQSSOXIBFFUt0cQEo6ezTjj377JPPMhTI8MUSQHzghioLtCCHEEJEkAgbdhegMQUQVUAwDZHp4ePPP6BIwIMQVTixQRiZaEDEFlm80EEkSnwgxBNAyFDBN/NoNY9I/CAxwQtGEIEDAnBw0MEORAghwwhKVMBCEEkAgUEK42hFDjjgePOMBQ0ckEABBOgbAAACDDAAAQ8owIABBDjQgAO8BAQAOw=="

        imgOutRight = "R0lGODlhHgASAOf7AAsjMAklQQYnOA8lNxAnPyAoOBosNRowPhUyRAoyfic1OgA4kRw3WCo3RABAmTA9SgNDoydAWRZBiABHnwBGsgtHjRtCkCxCYSREeQBJvgFOoAFNrRZIqQROpx5LeQ5OmgBQvSBQlwBWvRJVlQBWygRZuDBSfAVarAJX0wBbyB1YpQ5btQBd0Q1Z1SdYkwBhuQBhxwBf2xdcywBh4wJi1xhevjRcjBpexSRfnwhlxRtirgBnzB5e1DFfmx9itgBm7yhjnRFowSlmmgBr5hZl4gBs4ABr7SBpowBu1Bhn1Rhozxhn3EpkbUNjjhdsuABu6ABw4gBy0Ddolwpv3QBw8QBy3ght+FRjgCBp5gBx+Q5v5ABz7RBv7DxskgB36wB45RVz2gB64FJoqU1smAR82wB+1Rt21gB94T9wuWFqlAp69gB/6wCA5Td0vAB/+QCA80l1mRN960tytxN/3xZ98ih56DZ51TZ6zwCI5y559x2B6GF1mAaI7gWM3QCM8U55yyCF3i6D0DOA4gCP6iKH2hOI/TGD1xKJ90GCt1x8pmV8mUCB1wCR9ymH6E+Bv1d/vnB8lACV7GKBnC6I8DyH4z6H6l2CyAyX9gCb+TSO6T6N2yOU5m+Go0CQ2ACg+FOM0HeGpEuO13SHq2qLsjOY5X2Jol6Qy3mMpGePwhek4R+g8jKb7nKRrW6SsyKk7GKUz0aZ9Teg7XeU1nGYxUeh6HOax3qYx4SbuGue63ygtW6h2YOfwjOx/Xqg4W2m0ZmdrECx94qf0GKq4GCs74enw0y084Gn8GGx7Di9/4Kq5kq850W/9jzD842v5Ve/+WK891q+/4a240HJ/5a2xYu52VvG+Ke9r6y7zm3K/qW921fR/3jI/mXO/2zN+pLL95TP573J16vP2MfJxqrO69XZyNfZ1s/l7s/s6eDp8ejq59/v9uzx9Pbz+OT67P307ev4///09fb2//D69P32///2/Pb98vH+//r8+f/7+f/+4fX/+v78//j+///+7//+9f3//CH+EUNyZWF0ZWQgd2l0aCBHSU1QACwAAAAAHgASAAAI/gCjCcpESRAgQ82MUcJDiFKlQOM6acpkp9KkT/Lu7fOHb5++d4tazIhTBowRXHViaAEzxQglYzyMTKmzhUYlffs26uPn79ydLbyYIdMSyJcSPcikuYJhSliOPsykbUoyy94+fvXY7cs3LkgZaMuARfmTrAYfZdpi0QiFC4YqacUayaBWb9+/f/T+scsmI8+zaqtmWOrFglS3Z5FQoHpFAhg3Z3RKhOs3758/fpZlFebWTVWKWq9S0OKGrc6NWn+IeErFqIgPcxr9Xd0XD1EOWN22EVqhq00SXsBcUXEyKwkST57wxECjjt/Vuv/aoYkx7Ju3Lyt2HRnCB9MgGnJa/onYEumSHhKO5OHFtxMfOiFmnh1jhOSILR1GLvV5g35WhzOMHBKZKRr9I88+7phzAhKF4AEIC3KMsoEWjEQSRwa2wMFDGIMw4oUDxFylzz/4rCMFDHp4UQgSHwTzAXd8rAHDI4mcAEUcfpzRASo5jfhPPU2I8AUbeBQxQS42LPEGHl8kgQMrKjwxxxterNDFO3nhgw8/kmiwhRtrDKEBJ4ls8AUZYSwRQik97BBHHGqIAIQ6svGDjzu3mBlGFk9swIkiFGThRRhaVCCKGCKEwcYWLLgAzj7w/MPPPddYUAQUVXjBwR6QTDCEFWpMsQArY4BQRKZKVDCNbB7xQw4GaDyAocUPL3QhSQVFIBFGERCAksYHslqBhQOn6MMqP+uYsMETRgyRgwRXjFADFkbQoIEHiiSwRBFFEOEAE/f8c0+4//wSQQQPHIAAAg80MIAAAAwQAAENGEAAAwUowMAF1ohTTjnphBsQADs="
        self.phInLeft = PhotoImage(data=bytes(imgInLeft, 'latin1'))
        self.phInRight = PhotoImage(data=bytes(imgInRight, 'latin1'))
        self.phOutLeft = PhotoImage(data=bytes(imgOutLeft, 'latin1'))
        self.phOutRight = PhotoImage(data=bytes(imgOutRight, 'latin1'))

        self.updateUI()
Ejemplo n.º 30
0
    def initUI(self):
        self.parent.title("Submenu")

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        fileMenu = Menu(menubar)

        submenu = Menu(fileMenu)
        submenu.add_command(label="New Feed")
        submenu.add_command(label="Bookmarks")
        submenu.add_command(label="Mail")
        fileMenu.add_cascade(label="Import", menu=submenu, underline=0)

        fileMenu.add_separator()

        fileMenu.add_command(label="Exit", underline=0, command=self.onExit)
        menubar.add_cascade(label="File", underline=0, menu=fileMenu)
Ejemplo n.º 31
0
def _quit():
    win.quit()
    win.destroy()
    exit()


# Creating a Menu Bar
menuBar = Menu(win)
win.config(menu=menuBar)

# Add menu items
fileMenu = Menu(menuBar, tearoff=0)
fileMenu.add_command(label="新建")
fileMenu.add_separator()
fileMenu.add_command(label="退出", command=_quit)
menuBar.add_cascade(label="文件", menu=fileMenu)


# Display a Message Box
def _msgBox1():
    mBox.showinfo('Python Message Info Box', '通知:程序运行正常!')


def _msgBox2():
    mBox.showwarning('Python Message Warning Box', '警告:程序出现错误,请检查!')


def _msgBox3():
    mBox.showwarning('Python Message Error Box', '错误:程序出现严重错误,请退出!')

Ejemplo n.º 32
0
class NewMenuDemo(Frame):  # an extended frame
    """
    Menu demo
    """
    def __init__(self, parent=None):  # attach to top-level?
        """
        Constructor
        :param parent: the parent
        """
        # do superclass init
        super().__init__(parent)  # Same as super(__class__, self, parent) and
                                  # Frame.__init__(self, parent) from Python 2.x
        self.pack(expand=YES, fill=BOTH)
        self.createWidgets()  # attach frames/widgets
        self.master.title("Toolbars and Menus")  # set window-manager info
        self.master.iconname("tkpython")  # label when iconified

    def createWidgets(self):
        """
        Builds the widgets
        """
        self.makeMenuBar()
        self.makeToolBar()
        lab = Label(self, text='Menu and Toolbar Demo')
        lab.config(relief=SUNKEN, width=40, height=10, bg='white')
        lab.pack(expand=YES, fill=BOTH)

    def makeToolBar(self):
        """
        Builds the toolbar
        """
        toolbar = Frame(self, cursor='hand2', relief=SUNKEN, bd=2)
        toolbar.pack(side=BOTTOM, fill=X)
        Button(toolbar, text='Quit', command=self.quit).pack(side=RIGHT)
        Button(toolbar, text='Hello', command=self.greeting).pack(side=LEFT)

    def makeMenuBar(self):
        """
        Builds the menubar
        """
        self.menubar = Menu(self.master)
        self.master.config(menu=self.menubar)  # master=top-level window
        self.fileMenu()
        self.editMenu()
        self.imageMenu()

    def fileMenu(self):
        """
        Builds the filemenu
        """
        pulldown = Menu(self.menubar)
        pulldown.add_command(label='Open...', command=self.notdone)
        pulldown.add_command(label='Quit', command=self.quit)
        self.menubar.add_cascade(label='File', underline=0, menu=pulldown)

    def editMenu(self):
        """
        Builds the editmenu
        """
        pulldown = Menu(self.menubar)
        pulldown.add_command(label='Paste', command=self.notdone)
        pulldown.add_command(label='Spam', command=self.greeting)
        pulldown.add_separator()
        pulldown.add_command(label='Delete', command=self.greeting)
        pulldown.entryconfig(4, state=DISABLED)
        self.menubar.add_cascade(label='Edit', underline=0, menu=pulldown)

    def imageMenu(self):
        """
        Builds the imagemenu
        """
        photoFiles = ('ora-lp4e.gif', 'pythonPowered.gif', 'python_conf_ora.gif')
        pulldown = Menu(self.menubar)
        self.photoObjs = []
        for file in photoFiles:
            img = PhotoImage(file='../gifs/' + file)
            pulldown.add_command(image=img, command=self.notdone)
            self.photoObjs.append(img)  # keep a reference
        self.menubar.add_cascade(label='Image', underline=0, menu=pulldown)

    def greeting(self):
        """
        Pops up a greeting dialog
        """
        showinfo('greeting', 'Greetings')

    def notdone(self):
        """
        Not done yet handler
        """
        showerror('Not implemented', 'Not yet available')

    def quit(self):
        """
        Quits the application after requesting confirm
        """
        if askyesno('Verify quit', 'Are you sure you want to quit?'):
            Frame.quit(self)
Ejemplo n.º 33
0
    command=open_file,
)
file_menu.add_command(
    label="Save",
    accelerator="Ctrl+S",
    compound="left",
    image=save_file_icon,
    underline=0,
    command=save,
)
file_menu.add_command(label="Save as",
                      accelerator="Shift+Ctrl+S",
                      command=save_as)
file_menu.add_separator()
file_menu.add_command(label="Exit", accelerator="Alt+F4")
menu_bar.add_cascade(label="File", menu=file_menu)

edit_menu = Menu(menu_bar, tearoff=0)
edit_menu.add_command(label="Undo",
                      accelerator="Ctrl+Z",
                      compound="left",
                      image=undo_icon,
                      command=undo)
edit_menu.add_command(label="Redo",
                      accelerator="Ctrl+Y",
                      compound="left",
                      image=redo_icon,
                      command=redo)
edit_menu.add_separator()
edit_menu.add_command(label="Cut",
                      accelerator="Ctrl+X",
Ejemplo n.º 34
0
def _quit():
    win.quit()
    win.destroy()
    exit()


# Creating a Menu Bar
menuBar = Menu(tab1)
win.config(menu=menuBar)

# Add menu items
fileMenu = Menu(menuBar, tearoff=0)
fileMenu.add_command(label="New")
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command=_quit)
menuBar.add_cascade(label="File", menu=fileMenu)

# Add another Menu to the Menu Bar and an item
helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label="About")
menuBar.add_cascade(label="Help", menu=helpMenu)

# Change the main windows icon
#win.iconbitmap(r'C:\Python34\DLLs\pyc.ico')

# Place cursor into name Entry
nameEntered.focus()
#======================
# Start GUI
#======================
win.mainloop()
Ejemplo n.º 35
0
#create main GUI
root=tk.Tk()
root.title("panda-the assistant app")
#root.iconbitmap('logo1.ico')
root.geometry("1100x800")
root.resizable(0,0)
root.config(background="white")

#creating menu bar
menubar=Menu(root)

#help option
helpmenu=Menu(menubar,tearoff=0)
helpmenu.add_command(label="About me",command=aboutme)
menubar.add_cascade(label="Help",menu=helpmenu)

#About option
aboutmenu=Menu(menubar,tearoff=0)
aboutmenu.add_command(label="About developer",command=aboutdeveloper)
menubar.add_cascade(label="About",menu=aboutmenu)

#exit option
exitmenu=Menu(menubar,tearoff=0)
exitmenu.add_command(label="Exit",command=Ex)
menubar.add_cascade(label="Exit",menu=exitmenu)

#put menubar in GUI
root.config(menu=menubar)

Ejemplo n.º 36
0
    def __init__(self, master):
        """Class builds GUI to control Waltz Telescope.
           Uses Tkinter for GUI functionality.
           Inherits from lx200commands.Lx200Commands class.
           This class provides functionality to talk to serial connection 
           using the lx200 protocol.
        """
        
        super().__init__()
        
        self.master = master
        master.title("Waltz Control Panel")
       
        #Store CET and UCT
        self.CET = ''
        self.UTC = ''
        
        #Store if telescope is waiting for slew to finish
        self.waiting=True
        
        ## Building up GUI Widgets ##
        
        #Menubars
        menubar=Menu(self.master)
        
        #Connection menu
        connectionmenu = Menu(menubar, tearoff=0)
        connectionmenu.add_command(label="Open Connection", command=self.open_connection_buttonclick)
        connectionmenu.add_command(label="Close Connection", command=self.close_connection_buttonclick)
        menubar.add_cascade(label="Connection", menu=connectionmenu)
        
        #settings_menu
        settings_menu=Menu(menubar, tearoff=0)
        settings_menu.add_command(label="Enable buttons",command=self.stop_waiting)
        settings_menu.add_command(label="Toggle Precision",command=super().toggle_precision)
        menubar.add_cascade(label="Settings",menu=settings_menu)
        
        
        
        #Pointing_stars_menu
        pointing_stars_menu=Menu(menubar, tearoff=0)
        pointing_stars_menu.add_command(label="Pointing Star", command=self.save_pointing_star)
        menubar.add_cascade(label="Save as", menu= pointing_stars_menu)
        
        #Special_positions_menu
        special_positions_menu=Menu(menubar, tearoff=0)
        special_positions_menu.add_command(label="Slew to Primary Mirror Position",command=self.primary_mirror_pos_buttonclick)
        special_positions_menu.add_command(label="Slew to Secondary Mirror Position",command=self.secondary_mirror_pos_buttonclick)
        special_positions_menu.add_command(label="Slew to Park Position",command=self.park_telescope_buttonclick)
        menubar.add_cascade(label="Special Positions",menu=special_positions_menu)
        
        
        #Show menubar
        self.master.config(menu=menubar)
        
        #Output frame
        output_frame=Frame(master)
        output_frame.grid(row=0,columnspan=3)

        self.LST_label = Label(output_frame,
                               font=('arial', 15, 'bold'),
                               text="LST")
        self.LST_label.grid(row=0,column=0)
        
        self.LST_display = Label(output_frame,
                                 font=('arial', 20, 'bold'),
                                 bg='light green')
        self.LST_display.grid(row=0, column=1,padx=10, pady=10)
        
        self.local_time_label= Label(output_frame,
                              font=('arial', 15, 'bold'),
                              text='LT')
        self.local_time_label.grid(row=0, column=3)
        
        self.local_time_display = Label(output_frame,
                                 font=('arial', 20, 'bold'),
                                 bg='light green')
        self.local_time_display.grid(row=0, column=4,padx=10,pady=10)
        
        self.UTC_label= Label(output_frame,
                              font=('arial', 15, 'bold'),
                              text='UTC')
        self.UTC_label.grid(row=0, column=5)
        
        self.UTC_display = Label(output_frame,
                                 font=('arial', 20, 'bold'),
                                 bg='light green')
        self.UTC_display.grid(row=0, column=6,padx=10,pady=10)
        
        
        
        self.RA_label= Label(output_frame,
                             font=('arial', 15, 'bold'),
                             text= "RA")
        self.RA_label.grid(row=1, column =0)
        
        self.RA_display= Label(output_frame,
                               font=('arial', 20, 'bold'), 
                               bg='light green')
        self.RA_display.grid(row=1, column =1)
        
        self.DEC_label= Label(output_frame,
                              font=('arial', 15, 'bold'),
                              text= "DEC")
        self.DEC_label.grid(row=1, column =3)
        
        self.DEC_display= Label(output_frame,
                                font=('arial', 20, 'bold'),
                                bg='light green')
        self.DEC_display.grid(row=1, column =4)
        
        self.HA_label= Label(output_frame,
                              font=('arial', 15, 'bold'),
                              text= "HA")
        self.HA_label.grid(row=1, column =5)
        
        self.HA_display= Label(output_frame,
                                    font=('arial', 20, 'bold'),
                                    bg='light green')
        self.HA_display.grid(row=1, column=6)
        
        #Interchange_frame
        #To interchange W<->E buttons and N<->S
        self.interchange_frame=Frame(master)
        self.interchange_frame.grid(row=1, column=0,pady=10)
        #Define Variables
        self.inter_WE=IntVar()
        self.inter_NS=IntVar()
        self.inter_NS_checkbox=Checkbutton(self.interchange_frame,
                                           text='N <> S',
                                           font=('arial', 10, 'bold'),
                                           variable=self.inter_NS,
                                           command=self.interchange_north_south)
        self.inter_NS_checkbox.grid(row=0,column=0,sticky='w',pady=5)
        
        
        self.inter_WE_checkbox=Checkbutton(self.interchange_frame,
                                           text='W <> E',
                                           font=('arial', 10, 'bold'), 
                                           variable=self.inter_WE,
                                           command=self.interchange_west_east)
        self.inter_WE_checkbox.grid(row=1,column=0,sticky='w',pady=5)
        
        
        
        #Control frame
        self.control_frame=Frame(master)
        self.control_frame.grid(row=1,column=1,pady=10)


        self.south_button = Button(self.control_frame,
                                   text="S",
                                   font=('arial', 20, 'bold'),
                                   bg='LightGrey',
                                   height = 1, 
                                   width = 2)
        self.south_button.grid(row=0,column=1)
        
        self.west_button = Button(self.control_frame,
                                  text="W",
                                  font=('arial', 20, 'bold'),
                                  bg='LightGrey',
                                  height = 1,
                                  width = 2)
        self.west_button.grid(row=1,column=0)
        
        self.east_button = Button(self.control_frame,
                                  text="E",
                                  font=('arial', 20, 'bold'),
                                  bg='LightGrey',
                                  height = 1,
                                  width = 2)
        self.east_button.grid(row=1,column=2)
        
        
        self.north_button = Button(self.control_frame,
                                   text="N",
                                   font=('arial', 20, 'bold'),
                                   bg='LightGrey',
                                   height = 1,
                                   width = 2)
        self.north_button.grid(row=2,column=1)
        
        self.stop_button = Button(self.control_frame,
                                  text="STOP",
                                  font=('arial',20, 'bold'),
                                  fg='White',
                                  bg='Red',
                                  activeforeground='Red',
                                  activebackground='White',
                                  command=super().stop_at_current_pos)
        self.stop_button.grid(row=3,column=0, columnspan=3, pady=10)

        #Radiobutton frame
        self.radiobutton_frame=Frame(master)
        self.radiobutton_frame.grid(row=1,column=2,pady=10)
        
        
        radiobutton_parameters=[('Slew',0,self.set_speed_max),
                                ('Find',1, self.set_speed_find),
                                ('Center',2, self.set_speed_center),
                                ('Guide',3, self.set_speed_guide)]
        
        self.speed=StringVar()
        #Initialize speed to guiding speed
        self.speed.set('Guide')
        
        for keyword, position, execute in radiobutton_parameters:
            self.speed_radiobutton= Radiobutton(self.radiobutton_frame,
                                                text=keyword,
                                                variable=self.speed,
                                                value=keyword,
                                                command=execute,
                                                font=('arial', 10, 'bold'))
            self.speed_radiobutton.grid(row=position,column=0,sticky=W)
        
        #Options Frame
        self.options_frame=Frame(master)
        self.options_frame.grid(row=0,column=3,padx=20)
     
        self.sync_button = Button(self.options_frame,
                                       text="Synchronize \n with Target",
                                       font=('arial', 12, 'bold'),
                                       bg='LightGrey',
                                       command=self.sync_yes_no,
                                       state='disabled')
        self.sync_button.grid(row=0,column=0,padx=5)
        
        
        
        
        #Target Frame
        self.target_frame=LabelFrame(master,
                                text='Select Target (apparent position)',
                                font=('arial', 15))
        self.target_frame.grid(row=1,rowspan=1,column=3,padx=20)
        
        self.HIP_label = Label(self.target_frame,
                               font=('arial', 15),
                               text="Hipparcos")
        self.HIP_label.grid(row=0,column=0)
        
        self.HIP_entry= Entry(self.target_frame,
                              font=('arial', 15))
        self.HIP_entry.grid(row=0, column=1,pady=10)
        
        
        self.target_ra_label = Label(self.target_frame,
                                     font=('arial', 15),
                                     text="RA \n [hh mm ss]")
        self.target_ra_label.grid(row=1,column=0)
        
        self.target_ra_entry= Entry(self.target_frame,
                                    font=('arial', 15))
        self.target_ra_entry.grid(row=1, column=1,pady=10)

        
        self.target_dec_label = Label(self.target_frame,
                                      font=('arial', 15),
                                      text="""DEC \n [°° mm ss]""")
        self.target_dec_label.grid(row=2,column=0)
        
        self.target_dec_entry= Entry(self.target_frame,
                                     font=('arial', 15))
        self.target_dec_entry.grid(row=2, column=1,pady=10)
        
        self.target_time_label= Label(self.target_frame,
                                     font=('arial', 15),
                                     text=" Obs \n Time")
        self.target_time_label.grid(row=0,column=2,padx=10)
        
        self.target_time_display=Label(self.target_frame,
                                    font=('arial', 15),
                                    bg='red',
                                    width=10)
        self.target_time_display.grid(row=0,column=3,pady=10)
        
        self.target_alt_label = Label(self.target_frame,
                                     font=('arial', 15),
                                     text="ALT")
        self.target_alt_label.grid(row=1,column=2,padx=10)
        
        self.target_alt_display= Label(self.target_frame,
                                    font=('arial', 15),
                                    bg='red',
                                    width=10)
        self.target_alt_display.grid(row=1, column=3,pady=10)
        
        self.target_az_label = Label(self.target_frame,
                                     font=('arial', 15),
                                     text="AZ")
        self.target_az_label.grid(row=2,column=2,padx=10)
        
        self.target_az_display= Label(self.target_frame,
                                    font=('arial', 15),
                                    bg='red',
                                    width=10)
        self.target_az_display.grid(row=2, column=3,pady=10)
        
        self.slew_target_button = Button(self.target_frame,
                                         text="Slew to Target",
                                         font=('arial', 15),
                                         bg='LightGrey',
                                         state='disabled',
                                         command=self.slew_to_target_buttonclick)
        self.slew_target_button.grid(row=3,columnspan=4)
        
        #Plot Frame
        self.plot_frame=Frame(master)
        self.plot_frame.grid(row=2,columnspan=4)
        #Add instance variables to store the plot and the different axes,
        #and positions globally
        self.canvas=False
        self.ax1=False
        self.star_plot=False
        self.traj_plot=False
        self.pos_plot=False
        self.ax2=False
        
        #At first check if serial connection is open (also contains initial commands)
        self._respond_to_connection_state()
        
        #Message box for Warning
        caution=("CAUTION: THIS IS A FIRST ATTEMPT TO CONTROL THE WALTZ TELESCOPE.\n"+
                 "BAD INPUTS OR CRASHES OF THE PROGRAM COULD BE HARMFUL TO THE TELESCOPE.\n"+
                 "DO NOT USE THIS PROGRAM ALONE AND ALWAYS PREPARE FOR STOPING MOVEMENTS "+ 
                 "OF THE TELESCOPE VIA THE EMERGENCY STOPS IN THE DOME!")
        messagebox.showwarning("Warning",message=caution,parent=master)
Ejemplo n.º 37
0
        bg = canvas.create_image(0, 0, anchor=tk.NW, image=img)


#Create a Frame for displaying the app list
frame = tk.Frame(root)  #,bg="skyblue",)
frame.place(relwidth=0.8, relheight=0.5, relx=0.1, rely=0.1)
label1 = tk.Label(frame, text="Your workspace :")
label1.pack()

menubar = Menu(root)

filemenu = Menu(menubar)
filemenu.add_command(label='Save Workspace', command=BF.saveFile)
filemenu.add_command(label='Load Workspace', command=BF.loadFile)
filemenu.add_command(label='Modify Default Location')
menubar.add_cascade(label="Workspace", menu=filemenu)

settings = Menu(menubar)
settings.add_command(label='Set Background', command=setbackground)
settings.add_command(label='Change default location')
menubar.add_cascade(label='Settings', menu=settings)

button_clearApps = tk.Button(root,
                             text="Clear Set Apps",
                             fg="black",
                             bg="#f7cac9",
                             command=BF.clearapps)
button_clearApps.pack(side=tk.LEFT, padx=5, pady=5)

button_runApps = tk.Button(root,
                           text="Start my Workspace",
Ejemplo n.º 38
0
from tkinter import scrolledtext
from tkinter import messagebox
from tkinter.ttk import Progressbar
from tkinter import ttk
from tkinter import filedialog
from tkinter import Menu
#set window
window = Tk()
window.title("welcome noobs")
window.geometry("700x550")
#set menu
menu = Menu(window)
new_item = Menu(menu)
new_item.add_command(label="New")
new_item.add_command(label="Edit")
menu.add_cascade(label="File", menu=new_item)
window.config(menu=menu)


#create functions
def buttonClicked():
    res = textField.get()
    label.configure(text=res)


def radioButtonClicked():
    print(selected.get())


def messageButtonClicked():
    messagebox.showinfo("Title", "Content")
Ejemplo n.º 39
0
                         width=341)
mergeSortButton.place(x=400, y=500)

quickSortButton = Button(root,
                         image=quickPhoto,
                         command=quickSortClicked,
                         border=0,
                         height=190,
                         width=341)
quickSortButton.place(x=780, y=500)

menu = Menu(root)
root.config(menu=menu)

Searchmenu = Menu(menu)
Searchmenu = Menu(menu, tearoff=0)
menu.add_cascade(label='Searching', menu=Searchmenu)
Searchmenu.add_command(label='Linear Search', command=linearSearchClicked)
Searchmenu.add_command(label='Binary Search', command=binarySearchClicked)

Sortmenu = Menu(menu)
Sortmenu = Menu(menu, tearoff=0)
menu.add_cascade(label='Sorting', menu=Sortmenu)
Sortmenu.add_command(label='BubbleSort', command=bubbleSortClicked)
Sortmenu.add_command(label='SelectionSort', command=selectionSortClicked)
Sortmenu.add_command(label='InsertionSort', command=insertionSortClicked)
Sortmenu.add_command(label='HeapSort', command=heapSortClicked)
Sortmenu.add_command(label='MergeSort', command=mergeSortClicked)
Sortmenu.add_command(label='QuickSort', command=quickSortClicked)

root.mainloop()
Ejemplo n.º 40
0
class MainGUI:
    def __init__(self,player_filename=""):
        
        
        ############### load data and save settings
        self.save_on = True
        
        if not player_filename:
            player_filename = "data/character_template.json"
            self.save_on = False
        
        self.player_filename = player_filename
        
        with open(player_filename, 'r') as f:
            self.playerdata = json.load(f)
            
        self.player_class_data = data["classes"][self.playerdata["class"]]
        
        
            ##########
        
        self.root = Tk()
        
        
        

        
        
        ### variables
        
        self.levelvar = IntVar()
        self.levelvar.set(self.playerdata["level"])
        
        self.namevar = StringVar()
        self.namevar.set(self.playerdata["name"])
        
        self.goldvar = IntVar()
        self.goldvar.set(self.playerdata["gold"])
        
        self.background_text = self.playerdata["background"]
        
        self.journal_text = self.playerdata["journal"]
        
        ##############################
        #add widgets
        self.GUIMenu()
        
        self.GUIHeader()
        
        self.GUIBody()
        
        
        
        ##############################
        
        
        ### configure root
        self.root.grid_rowconfigure(0, weight=0)
        self.root.grid_rowconfigure(1, weight=1,minsize=400)
        self.root.grid_columnconfigure(0, weight=1,minsize=400)
        
        
        self.root.title("RPG Leveler")
        self.root.protocol("WM_DELETE_WINDOW", self.on_close)
        self.root.mainloop()
        
        
        
    ##############################
    #   Constructor functions    #
    ##############################
        
        
        
        ### add menu
    def GUIMenu(self):
        self.menubar = Menu(self.root)
        
        self.fileMenu = Menu(self.menubar, tearoff=0)
        self.fileMenu.add_command(label="Open", command=self.open_file)
        self.fileMenu.add_command(label="Save", command=self.save)
        self.fileMenu.add_separator()
        self.fileMenu.add_command(label="Exit", command=self.root.quit)
        self.menubar.add_cascade(label="File", menu=self.fileMenu)
        
        self.spellMenu = Menu(self.menubar, tearoff=0)
        self.spellMenu.add_command(label="Add Spell", command=OpenGUI)
        self.spellMenu.add_command(label="Edit Spell", command=self.hello)
        self.menubar.add_cascade(label="Spells", menu=self.spellMenu)
        
        self.itemMenu = Menu(self.menubar, tearoff=0)
        self.itemMenu.add_command(label="Add Item", command=self.hello)
        self.itemMenu.add_command(label="Edit Item", command=self.hello)
        self.menubar.add_cascade(label="Items", menu=self.itemMenu)
        
        self.root.config(menu=self.menubar)
        
        
        
        
        
        
        
        ### add header
        
        
    def GUIHeader(self):
        
        self.header = Frame(self.root,pady=5)
        
        
        self.header_name = Label(self.header,text="Name: ")
        self.header_namevar = Label(self.header,textvariable=self.namevar)
        
        self.header_level = Label(self.header,text="Level: ")
        self.header_levelvar = Label(self.header,textvariable=self.levelvar)
        
        self.header_gold = Label(self.header,text="Gold: ")
        self.header_goldvar = Label(self.header,textvariable=self.goldvar)
        
        
        
        self.header.grid(row=0,column=0,sticky="NSEW")
        
        self.header_name.grid(row=0,column=0,sticky="NSEW")
        self.header_namevar.grid(row=0,column=1,sticky="NSEW")
        
        self.header_level.grid(row=0,column=3,sticky="NSEW")
        self.header_levelvar.grid(row=0,column=4,sticky="NSEW")
        
        self.header_gold.grid(row=0,column=6,sticky="NSEW")
        self.header_goldvar.grid(row=0,column=7,sticky="NSEW")
        
        
        
        ### configure header grid
        
        self.header.grid_columnconfigure(2,minsize=30,weight=2)
        self.header.grid_columnconfigure(5,minsize=30,weight=2)
        self.header.grid_columnconfigure(8,weight=5)
        
        
        
    def GUIBody(self):
        
        #notebook
        self.body = ttk.Notebook()
        
        self.tabAbilities = Frame(self.root)
        self.tabClass = Frame(self.root)
        self.tabSkills = Frame(self.root)
        self.tabItems = Frame(self.root)
        self.tabBackground = Frame(self.root)
        self.tabJournal = Frame(self.root)
        
        ###########################
        #add tabs
        self.GUIAbilitiesTab()
        self.GUIBackgroundTab()
        self.GUIClassTab()
        self.GUIItemsTab()
        self.GUIJournalTab()
        self.GUIOverviewTab()
        self.GUISkillsTab()
        #
        ###########################
        self.body.add(self.tabAbilities,text="Abilities")
        self.body.add(self.tabClass,text=self.player_class_data["tab_name"])
        self.body.add(self.tabSkills,text="Skills")
        self.body.add(self.tabItems,text="Items")
        self.body.add(self.tabBackground,text="Background")
        self.body.add(self.tabJournal,text="Journal")
        

        self.body.grid(row=1,column=0,sticky="NSEW")
     
     
     
        
    ##################################
    #            tabs                #
    ##################################
        
        

    def GUIBackgroundTab(self):
        self.background_box = Text(self.tabBackground,width=10,height=10,font="TkFixedFont",wrap=WORD)
        self.background_box.insert(END,self.background_text)
        self.background_box.grid(row=0,column=0,sticky="NSEW")
        self.tabBackground.grid_rowconfigure(0, weight=1)
        self.tabBackground.grid_columnconfigure(0, weight=1)


    

    def GUIJournalTab(self):
        self.journal_box = Text(self.tabJournal,width=10,height=10,font="TkFixedFont",wrap=WORD)
        self.journal_box.insert(END,self.journal_text)
        self.journal_box.grid(row=0,column=0,sticky="NSEW")
        self.tabJournal.grid_rowconfigure(0, weight=1)
        self.tabJournal.grid_columnconfigure(0, weight=1)
        
        
        
    def GUIAbilitiesTab(self):
        
        
        self.Attributes = {}
        self.i=0
        self.Abilities_pointsLeftvar = IntVar()
        self.Abilities_pointsLeftvar.set(self.playerdata["points"]["attributes"])
        
        #header
        self.tabAbilities_abil = Frame(self.tabAbilities,padx=10,pady=10)
        self.tabAbilities_pointsLeft = Label(self.tabAbilities,text="Points Left:")
        self.tabAbilities_pointsLeftvar = Label(self.tabAbilities,textvariable=self.Abilities_pointsLeftvar)
        
        
        
        #attributes
        for attribute in self.playerdata["stats"]["attributes"]:
                #print(attribute)
                self.Attributes[attribute] = {}
                self.Attributes[attribute]["value"] = IntVar()
                self.Attributes[attribute]["value"].set(self.playerdata["stats"]["attributes"][attribute])
                
                self.Attributes[attribute]["button+"] = Button(self.tabAbilities_abil,text="+",command=lambda attribute=attribute: self.change_attribute(attribute,1))
                self.Attributes[attribute]["button-"] = Button(self.tabAbilities_abil,text="-",command=lambda attribute=attribute: self.change_attribute(attribute,-1))
                self.Attributes[attribute]["valueLabel"] = Label(self.tabAbilities_abil,textvariable=self.Attributes[attribute]["value"],font=("Ariel", 25))
                self.Attributes[attribute]["atributeLabel"] = Label(self.tabAbilities_abil,text=attribute.upper()+" ",font=("Ariel", 25))
                self.Attributes[attribute]["spacerLabel"] = Label(self.tabAbilities_abil,text="",height=1)
                
                self.Attributes[attribute]["atributeLabel"].grid(row=self.i,column=0,sticky="NSEW",rowspan=2)
                self.Attributes[attribute]["button-"].grid(row=self.i+1,column=4,sticky="NSEW")
                self.Attributes[attribute]["valueLabel"].grid(row=self.i,column=2,sticky="NSEW",rowspan=2)
                self.Attributes[attribute]["button+"].grid(row=self.i,column=4,sticky="NSEW")
                self.Attributes[attribute]["spacerLabel"].grid(row=self.i+2,column=3,sticky="NSEW")
                
                self.i+=3
        
        self.tabAbilities_pointsLeftvar.grid(row=0,column=2)
        self.tabAbilities_pointsLeft.grid(row=0,column=1)
        self.tabAbilities_abil.grid(row=1,column=0)


        
    def GUISkillsTab(self):

        self.Skills = {}
        self.sk_x=0
        self.sk_y=0
        
        
        #attributes
        for skill in data["stats"]["skills"]:
            
            #print(skill)
            self.Skills[skill["name"]] = {}
            
            self.Skills[skill["name"]]["frame"] = Frame(self.tabSkills,relief="sunken",bd=1)
            
            self.Skills[skill["name"]]["isTrained"] = IntVar()
            self.Skills[skill["name"]]["isTrained"].set(self.playerdata["stats"]["skills"][skill["name"]])
            
            self.Skills[skill["name"]]["value"] = IntVar()
            self.Skills[skill["name"]]["value"].set((self.Attributes[skill["base"]]["value"].get()-10)//2+self.Skills[skill["name"]]["isTrained"].get()*2)
            
            #print (self.Skills[skill["name"]]["value"].get())
            
            self.Skills[skill["name"]]["check"] = Checkbutton(self.Skills[skill["name"]]["frame"],variable=self.Skills[skill["name"]]["isTrained"],state=DISABLED,command=lambda skill=skill: print(skill))
            self.Skills[skill["name"]]["valueLabel"] = Label(self.Skills[skill["name"]]["frame"],textvariable=self.Skills[skill["name"]]["value"],font=("Ariel", 12))
            self.Skills[skill["name"]]["atributeLabel"] = Label(self.Skills[skill["name"]]["frame"],text=skill["name"]+" ",font=("Ariel", 12))
            
            
            self.Skills[skill["name"]]["frame"].grid(row=self.sk_y,column=self.sk_x,sticky="we")
            
            self.Skills[skill["name"]]["check"].pack(side="left")
            self.Skills[skill["name"]]["atributeLabel"].pack(side="left")
            self.Skills[skill["name"]]["valueLabel"].pack(side="right")
            
            
            self.sk_x+=1
            if self.sk_x > 1:
                self.sk_y+=1
                self.sk_x=0
        


        ######## Items
    def GUIItemsTab(self):
        
        
        self.itemSFrame = FrameScrollbar(self.tabItems)
            
        self.itemid=0
        self.Items = []
        
        for item in self.playerdata["items"]:
            
            self.Items.append({})
            self.Items[self.itemid]["id"]=self.itemid
            self.Items[self.itemid]["frame"] = Frame(self.itemSFrame.frame,relief=RIDGE,bg="grey",padx=1,pady=1)
            self.Items[self.itemid]["button_delete"] = Button(self.Items[self.itemid]["frame"],text="X",fg="white",bg="red",command=lambda Itemid=self.itemid:delItem(Itemid))
            self.Items[self.itemid]["name"] = Entry(self.Items[self.itemid]["frame"])
            self.Items[self.itemid]["name"].insert(END, item["name"])
            self.Items[self.itemid]["description"] = Text(self.Items[self.itemid]["frame"],width=10,height=5,wrap=WORD)
            self.Items[self.itemid]["description"].insert(END,item["description"])
            
            self.Items[self.itemid]["name"].grid(row=0,column=0)
            self.Items[self.itemid]["button_delete"].grid(row=0,column=0,sticky="E")
            self.Items[self.itemid]["description"].grid(row=1,column=0,sticky="NSEW")
            self.Items[self.itemid]["frame"].grid(padx=10,pady=10,sticky="EW")
            
            self.Items[self.itemid]["frame"].grid_columnconfigure(0, weight=1)
            
            
            
            self.itemid+=1
            
        def addItem():
            item={}
            item["id"]=self.itemid
            item["frame"] = Frame(self.itemSFrame.frame,relief=RIDGE,bg="grey",padx=1,pady=1)
            item["button_delete"] = Button(item["frame"],text="X",fg="white",bg="red",command=lambda Itemid=self.itemid:delItem(Itemid))
            item["name"] = Entry(item["frame"])
            item["description"] = Text(item["frame"],width=10,height=5,wrap=WORD)
            item["name"].grid(row=0,column=0)
            item["button_delete"].grid(row=0,column=0,sticky="E")
            item["description"].grid(row=1,column=0,sticky="NSEW")
            item["frame"].grid(padx=20,pady=10,sticky="EW")
            item["frame"].grid_columnconfigure(0, weight=1)
            
            self.itemSFrame.frame.update_idletasks()
            self.itemSFrame.onCanvasConfigure(None)
            
            
            
            self.Items.append(item)
            
            self.itemid+=1
            
    
            
        def delItem(Itemid):
            item=""
            index=0
            for item in self.Items:
                if item["id"]==Itemid:
                    index=self.Items.index(item)
                    break
                else:
                    item=""
            if item:
                self.Items[index]["frame"].grid_remove()
                self.Items.remove(item)
                
            self.itemSFrame.frame.update_idletasks()
            self.itemSFrame.onCanvasConfigure(None)
        
        self.addItemButton = Button(self.itemSFrame.canvas_frame,text="+",bg="grey",command=addItem).place(rely=1.0, relx=0.0, x=5, y=-5, anchor="sw")
            
        ######## Class
    def GUIClassTab(self):
        pass

        ######## Overview
    def GUIOverviewTab(self):
        pass






        
        
        
        
        
        
        
    
    #######################################
    #            functions                #
    #######################################
        


    def hello(self):
        pass
    
    
    
    def change_attribute(self,attribute,amount):
        if amount>0:
            if self.Abilities_pointsLeftvar.get()>0:
                self.Attributes[attribute]["value"].set(self.Attributes[attribute]["value"].get()+amount)
                self.Abilities_pointsLeftvar.set(self.Abilities_pointsLeftvar.get()-1)
        else:
            if self.Attributes[attribute]["value"].get()>self.playerdata["stats"]["base_attributes"][attribute]:
                self.Attributes[attribute]["value"].set(self.Attributes[attribute]["value"].get()+amount)
                self.Abilities_pointsLeftvar.set(self.Abilities_pointsLeftvar.get()+1)
        self.updateSkills()
    
    
    def on_close(self):
        if self.save_on and messagebox.askyesno("RPG","Do you want to save changes?"):
            self.save()
        self.root.destroy()
    
    
    
    def save(self):
        if self.save_on:
            
            for attribute in self.playerdata["stats"]["attributes"]:
                self.playerdata["stats"]["attributes"][attribute] = self.Attributes[attribute]["value"].get()
                self.playerdata["items"]=[]
            for item in self.Items:
                ditem = {}
                ditem["name"]=item["name"].get()
                ditem["description"]=item["description"].get(1.0,END)[:-1]
                self.playerdata["items"].append(ditem)
            
            
            self.playerdata["level"] = self.levelvar.get()
            self.playerdata["name"] = self.namevar.get()
            self.playerdata["gold"] = self.goldvar.get() 
            self.playerdata["background"] = self.background_box.get(1.0,END)[:-1]
            self.playerdata["journal"] =  self.journal_box.get(1.0,END)[:-1]
            self.playerdata["points"]["attributes"] = self.Abilities_pointsLeftvar.get()
            
            print(self.playerdata)
            
            with open(self.player_filename, 'w') as player_file:
                json.dump(self.playerdata, player_file, indent=4)
        
    def updateSkills(self):
        for skill in data["stats"]["skills"]:
            self.Skills[skill["name"]]["value"].set((self.Attributes[skill["base"]]["value"].get()-10)//2+self.Skills[skill["name"]]["isTrained"].get()*2)
        
    def open_file(self):
        p_fn = openFileName()
        if p_fn:
            self.root.destroy()
            openGUI(p_fn)
Ejemplo n.º 41
0
############### MENUBAR 

menubar = Menu(root)  
file = Menu(menubar, tearoff=0)  
file.add_command(label="New")  
file.add_command(label="Open")  
file.add_command(label="Save")  
file.add_command(label="Save as...")  
file.add_command(label="Close")  
  
file.add_separator()  
  
file.add_command(label="Exit", command=root.destroy)  
  
menubar.add_cascade(label="File", menu=file) 
 
edit = Menu(menubar, tearoff=0)  
edit.add_command(label="Undo")  
edit.add_separator()    
edit.add_command(label="Cut")  
edit.add_command(label="Copy")  
edit.add_command(label="Paste")  
edit.add_command(label="Delete")  
edit.add_command(label="Select All")  
menubar.add_cascade(label="Edit", menu=edit)  

help = Menu(menubar, tearoff=0)  
help.add_command(label="About")  
menubar.add_cascade(label="Help", menu=help)  
  
Ejemplo n.º 42
0
LettresTrouvees = [Mot[0]]  #réinitialistation des lettres trouvees
LettresFausses = []
nbchance = 7  #On réinitialise les essais

#Création de la fenêtre principale
MyWindow = Tk()
MyWindow.title('Le pendu')  #Titre de la fenêtre
MyWindow.geometry('480x560+900+150')  #Taille de la fenêtre
MyWindow.configure(bg='white')  #On change la couleur du fond.

#Creation d'un menu
menubar = Menu(MyWindow)
menufichier = Menu(menubar, tearoff=0)
menufichier.add_command(label="Rejouer", command=Rejouer)
menufichier.add_command(label="Quitter", command=MyWindow.destroy)
menubar.add_cascade(label="Fichier", menu=menufichier)
MyWindow.config(menu=menubar)

#Importation de toutes les images
image1 = PhotoImage(master=MyWindow, file='bonhomme1.gif')
image2 = PhotoImage(master=MyWindow, file='bonhomme2.gif')
image3 = PhotoImage(master=MyWindow, file='bonhomme3.gif')
image4 = PhotoImage(master=MyWindow, file='bonhomme4.gif')
image5 = PhotoImage(master=MyWindow, file='bonhomme5.gif')
image6 = PhotoImage(master=MyWindow, file='bonhomme6.gif')
image7 = PhotoImage(master=MyWindow, file='bonhomme7.gif')
image8 = PhotoImage(master=MyWindow, file='bonhomme8.gif')

#Canevas
Largeur = 310
Hauteur = 320
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resizable(False, False)
        self.title('AUTOMATED GRAY CAST IRON GATING SYSTEM DESIGN')
        mb = Menu(self)  # creates menu bar
        self.config(menu=mb)
        fm = Menu(mb, tearoff=0)  # creates file menu item
        fm.add_command(label='New')
        fm.add_command(label='Clear Session', command=self._reset)
        fm.add_separator()
        mb.add_cascade(label="File", menu=fm)  # adds menu item to menu
        hl = Menu(mb, tearoff=0)
        hl.add_command(label='About', command=self._showcredits)
        mb.add_cascade(label='Help', menu=hl)
        fm.add_command(label='Exit', command=self._quit)

        self.f1 = ttk.LabelFrame(
            self, text='Phase One: Poured Weight And Pouring Time')
        self.f1.grid(row=0, column=0, sticky="NSWE", pady=(0, 0))
        self.input = ttk.LabelFrame(self.f1, text='Inputs')
        self.input.grid(row=0, column=0, padx=10, pady=10, sticky='NW')
        self.output = ttk.LabelFrame(self.f1, text='Outputs')
        self.output.grid(row=0,
                         column=1,
                         rowspan=1,
                         padx=10,
                         pady=10,
                         sticky='NE')
        self.poinputs = {
            'Casting Weight': 'kg',
            'Casting Volume': 'cub.mm',
            'Casting Length': 'mm',
            'Yield': '%',
            'Section Thickness': 'mm',
            'Fluidity Factor': 'inch',
            'Density of Solid GCI': 'kg/cub.mm',
            'Density of Liquid GCI': 'kg/cub.mm',
            'Metal Composition': '%C:%Si:%P'
        }
        self.pooutputs = {
            'PouredWeight': 'kg',
            'PouringTemperature': 'Celsius',
            'Fluidity': 'mm',
            'Pouring Time': 'Sec',
            'Pouring Rate': 'kg/s'
        }
        self.poinput = self.create_widget(self.input,
                                          self.poinputs,
                                          input=True)
        self.pooutput = self.create_widget(self.output, self.pooutputs)
        calc = ttk.Button(self.f1, text='Calc', command=self.pouring)
        calc.grid(row=2, column=0, sticky="NW")

        self.f2 = ttk.LabelFrame(self, text='Phase Two: Sprue Design')
        self.f2.grid(row=0, column=1, sticky='NSWE')
        self.input = ttk.LabelFrame(self.f2, text='Inputs')
        self.input.grid(row=0, column=0, padx=10, pady=10)
        self.output = ttk.LabelFrame(self.f2, text='Outputs')
        self.output.grid(row=0, column=1, rowspan=1, padx=10, pady=10)
        self.sprueinputs = {
            'Total Sprue Height': 'mm',
            'Height in Cope': 'mm',
            'Height of Mould Cavity': 'mm',
            'Basin Head': 'mm'
        }
        self.sprueoutputs = {
            'Sprue Effect. Height': 'mm',
            'Sprue Choke Area': 'sq.mm',
            'Sprue Top Area': 'sq.mm',
            'Base Well Area': 'sq.mm',
            'Choke Diameter': 'mm',
            'Top Diameter': 'mm',
            'Choke Length': 'mm',
            'Top Length': 'mm'
        }
        self.t = ttk.LabelFrame(self.input, text="Sprue Tapering")
        self.g = ttk.LabelFrame(self.input, text="Gating")
        self.g.grid(row=0, column=0, columnspan=1, sticky='EW')
        self.t.grid(row=0, column=1, sticky='WE')
        self.lf = ttk.LabelFrame(self.input)
        self.lf.grid(row=0, column=2, sticky='WE')
        self.cfd = ttk.Label(self.lf,
                             text='Efficiency Factor').grid(row=0,
                                                            column=0,
                                                            sticky='NS')
        self.cf = tk.Spinbox(self.lf,
                             textvar=tk.DoubleVar(),
                             from_=0.7,
                             to=0.9,
                             increment=0.01,
                             state='readonly',
                             bd=5,
                             width=4)
        self.cf.grid(row=1, column=0, sticky="WE")
        self.gt = tk.IntVar()
        self.st = tk.IntVar()
        self.to = ttk.Radiobutton(self.g,
                                  text='Top',
                                  value=1,
                                  variable=self.gt,
                                  state='active',
                                  command=self.cc).grid(row=0,
                                                        column=0,
                                                        sticky='WE')
        self.pt = ttk.Radiobutton(self.g,
                                  text='Parting',
                                  value=2,
                                  variable=self.gt,
                                  command=self.cc).grid(row=1,
                                                        column=0,
                                                        sticky='WE')
        self.bo = ttk.Radiobutton(self.g,
                                  text='Bottom',
                                  value=3,
                                  variable=self.gt,
                                  command=self.cc).grid(row=2,
                                                        column=0,
                                                        sticky='WE')
        self.tc = ttk.Radiobutton(self.t,
                                  text='Circular',
                                  value=2,
                                  variable=self.st).grid(row=0,
                                                         column=0,
                                                         sticky='WE')
        self.ts = ttk.Radiobutton(self.t,
                                  text='Square',
                                  value=1,
                                  variable=self.st).grid(row=2,
                                                         column=0,
                                                         sticky='WE')
        self.sinputs = self.create_widget(self.input,
                                          self.sprueinputs,
                                          x=1,
                                          input=True)
        self.soutputs = self.create_widget(self.output, self.sprueoutputs)
        self.calc2 = ttk.Button(self.f2,
                                text='Calc',
                                command=self.spruedesign,
                                state='disabled')
        self.calc2.grid(row=1, column=1, sticky='NE')

        self.f3 = ttk.LabelFrame(
            self, text='Phase Three: Ingate and Pouring Basin Design')
        self.f3.grid(row=1, column=0, sticky='NSWE')
        self.input = ttk.LabelFrame(self.f3, text='Inputs')
        self.input.grid(row=0, column=0, padx=10, pady=10)
        self.output = ttk.LabelFrame(self.f3, text='Outputs')
        self.output.grid(row=0, column=1, rowspan=1, padx=10, pady=10)
        self.gateinputs = {
            'Number of Ingates': '',
            'Aspect Ratio(H:W)': '',
            'Gating Ratio(S:R:I)': ''
        }
        self.gateoutputs = {
            'Basin Depth': 'mm',
            'Ingate Area': 'sq.mm',
            'Ingate Height': 'mm',
            'Ingate Width': 'mm'
        }
        self.ginputs = self.create_widget(self.input,
                                          self.gateinputs,
                                          input=True)
        self.goutputs = self.create_widget(self.output, self.gateoutputs)
        self.calc3 = ttk.Button(self.f3,
                                text='Calc',
                                state='disabled',
                                command=self.ingatedesign)
        self.calc3.grid(row=1, column=0, sticky='SW')

        self.f4 = ttk.LabelFrame(self, text='Phase Four: Runner Design')
        self.f4.grid(row=1, column=1, sticky="NSWE", pady=(0, 0))
        self.input = ttk.LabelFrame(self.f4, text='Inputs')
        self.input.grid(row=0, column=0, padx=10, pady=10, sticky='SW')
        self.output = ttk.LabelFrame(self.f4, text='Outputs')
        self.output.grid(row=0,
                         column=1,
                         rowspan=1,
                         padx=(10, 0),
                         pady=10,
                         sticky='SE')
        self.runnerinputs = {'Number of Runners': '', 'Aspect Ratio (H:W)': ''}
        self.runneroutputs = {
            'Runner Area': 'sq.mm',
            'Runner Height': 'mm',
            'Runner Width': 'mm'
        }
        self.rinputs = self.create_widget(self.input,
                                          self.runnerinputs,
                                          input=True)
        self.routputs = self.create_widget(self.output, self.runneroutputs)
        self.calc4 = ttk.Button(self.f4,
                                text='Calc',
                                state='disabled',
                                command=self.runnerdesign)
        self.calc4.grid(row=1, column=1, sticky='SE')
 def createWidgets(self):    
     # Tab Control introduced here --------------------------------------
     tabControl = ttk.Notebook(self.win)     # Create Tab Control
     
     tab1 = ttk.Frame(tabControl)            # Create a tab 
     tabControl.add(tab1, text='Tab 1')      # Add the tab
     
     tab2 = ttk.Frame(tabControl)            # Add a second tab
     tabControl.add(tab2, text='Tab 2')      # Make second tab visible
     
     tabControl.pack(expand=1, fill="both")  # Pack to make visible
     # ~ Tab Control introduced here -----------------------------------------
     
     # We are creating a container frame to hold all other widgets
     self.monty = ttk.LabelFrame(tab1, text=' Mighty Python ')
     self.monty.grid(column=0, row=0, padx=8, pady=4)        
     
     # Changing our Label
     ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
     
     # Adding a Textbox Entry widget
     self.name = tk.StringVar()
     nameEntered = ttk.Entry(self.monty, width=12, textvariable=self.name)
     nameEntered.grid(column=0, row=1, sticky='W')
     
     # Adding a Button
     self.action = ttk.Button(self.monty, text="Click Me!", command=self.clickMe)   
     self.action.grid(column=2, row=1)
     
     ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
     number = tk.StringVar()
     numberChosen = ttk.Combobox(self.monty, width=12, textvariable=number)
     numberChosen['values'] = (1, 2, 4, 42, 100)
     numberChosen.grid(column=1, row=1)
     numberChosen.current(0)
          
     # Adding a Spinbox widget using a set of values
     self.spin = Spinbox(self.monty, values=(1, 2, 4, 42, 100), width=5, bd=8, command=self._spin) 
     self.spin.grid(column=0, row=2)
               
     # Using a scrolled Text control    
     scrolW  = 30; scrolH  =  3
     self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
     self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)
     
     #-------------------------------------------------------------------------    
     # Adding another Button
     self.action = ttk.Button(self.monty, text="Clear Text", command=self.clearScrol)   
     self.action.grid(column=2, row=2)
     
                            
     # Tab Control 2 refactoring  -----------------------------------------
     # We are creating a container frame to hold all other widgets -- Tab2
     self.monty2 = ttk.LabelFrame(tab2, text=' Holy Grail ')
     self.monty2.grid(column=0, row=0, padx=8, pady=4)
     # Creating three checkbuttons
     chVarDis = tk.IntVar()
     check1 = tk.Checkbutton(self.monty2, text="Disabled", variable=chVarDis, state='disabled')
     check1.select()
     check1.grid(column=0, row=0, sticky=tk.W)                 
     
     self.chVarUn = tk.IntVar()
     self.check2 = tk.Checkbutton(self.monty2, text="UnChecked", variable=self.chVarUn)
     self.check2.deselect()
     self.check2.grid(column=1, row=0, sticky=tk.W )                  
      
     self.chVarEn = tk.IntVar()
     self.check3 = tk.Checkbutton(self.monty2, text="Toggle", variable=self.chVarEn)
     self.check3.deselect()
     self.check3.grid(column=2, row=0, sticky=tk.W)                 
 
     # trace the state of the two checkbuttons
     self.chVarUn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())    
     self.chVarEn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())   
     # ~ Tab Control 2 refactoring  -----------------------------------------
     
     # Radiobutton list
     colors = ["Blue", "Gold", "Red"]
     
     self.radVar = tk.IntVar()
     
     # Selecting a non-existing index value for radVar
     self.radVar.set(99)    
     
     # Creating all three Radiobutton widgets within one loop
     for col in range(3):
         curRad = 'rad' + str(col)  
         curRad = tk.Radiobutton(self.monty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall)
         curRad.grid(column=col, row=6, sticky=tk.W, columnspan=3)
         # And now adding tooltips
         ToolTip(curRad, 'This is a Radiobutton control.')
         
     # Create a container to hold labels
     labelsFrame = ttk.LabelFrame(self.monty2, text=' Labels in a Frame ')
     labelsFrame.grid(column=0, row=7)
      
     # Place labels into the container element - vertically
     ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
     ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)
     
     # Add some space around each label
     for child in labelsFrame.winfo_children(): 
         child.grid_configure(padx=8)
     
     
     # Creating a Menu Bar
     menuBar = Menu(tab1)
     self.win.config(menu=menuBar)
     
     # Add menu items
     fileMenu = Menu(menuBar, tearoff=0)
     fileMenu.add_command(label="New")
     fileMenu.add_separator()
     fileMenu.add_command(label="Exit", command=self._quit)
     menuBar.add_cascade(label="File", menu=fileMenu)
     
     # Add another Menu to the Menu Bar and an item
     helpMenu = Menu(menuBar, tearoff=0)
     helpMenu.add_command(label="About")
     menuBar.add_cascade(label="Help", menu=helpMenu)
     
     # Change the main windows icon
     self.win.iconbitmap('pyc.ico')
     
     # Using tkinter Variable Classes
     strData = tk.StringVar()
     strData.set('Hello StringVar')
     print(strData.get())
     
     # Default tkinter Variable Classes
     intData = tk.IntVar()
     print(intData.get())
     print(tk.DoubleVar())
     print(tk.BooleanVar())
     
     # It is not necessary to create a tk.StringVar() 
     strData = tk.StringVar()
     strData = self.spin.get()
     print("Hello " + strData)
     
     # Printing the Global works
     print(GLOBAL_CONST)
      
     # call method
     self.usingGlobal()
     
     # Place cursor into name Entry
     nameEntered.focus()     
     
     # Add a Tooltip to the Spinbox
     ToolTip(self.spin, 'This is a Spin control.')         
     
     # Add Tooltips to more widgets
     ToolTip(nameEntered, 'This is an Entry control.')  
     ToolTip(self.action, 'This is a Button control.')                      
     ToolTip(self.scr,    'This is a ScrolledText control.')
# Exit GUI cleanly
def _quit():
    win.quit()
    win.destroy()
    exit() 
    
# Creating a Menu Bar
menu_bar = Menu(win)
win.config(menu=menu_bar)

# Add menu items
file_menu = Menu(menu_bar, tearoff=0)
file_menu.add_command(label="New")
file_menu.add_separator()
file_menu.add_command(label="Exit", command=_quit)
menu_bar.add_cascade(label="File", menu=file_menu)

# Display a Message Box
def _msgBox():
    msg.showinfo('Python Message Info Box', 'A Python GUI created using tkinter:\nThe year is 2017.')  
    
# Add another Menu to the Menu Bar and an item
help_menu = Menu(menu_bar, tearoff=0)
help_menu.add_command(label="About", command=_msgBox)   # display messagebox when clicked
menu_bar.add_cascade(label="Help", menu=help_menu)

# Change the main windows icon
win.iconbitmap('pyc.ico')

name_entered.focus()      # Place cursor into name Entry
#======================
Ejemplo n.º 46
0
    def __init__(self):
        ##############################################VENTANA PRINCIPAL####################################
        self.window=Tk()
        #self.window.configure(background="#04DE5E")
       # img = PhotoImage(file='img/icons/postgesql2.png')
        #self.window.tk.call('wm', 'iconphoto', self.window._w, img)
        #img = PhotoImage(file='img/icons/Postgresql.ico')
        #self.window.tk.call('wm', 'iconphoto', self.window._w, img)
        self.window.configure(background="#6a8d92")
        self.window.title("Query Tool - Grupo 9")
        #w, h = self.window.winfo_screenwidth()/2, self.window.winfo_screenheight()/2
        w, h = 1370,670
        self.window.geometry("%dx%d+0+0" % (w, h))
        
        ##############################################MENU####################################
        menu = Menu(self.window)
        new_item = Menu(menu,tearoff=0)
        new_item.add_command(label='Abrir', command=self.abrir_click)
        new_item.add_command(label='Guardar', command=self.guardar_click)
        new_item.add_command(label='Guardar Como...', command=self.guardar_como_click)
        #new_item.add_separator()
        #new_item.add_command(label='Edit')
        menu.add_cascade(label='Archivo', menu=new_item)
        mnreportes = Menu(menu,tearoff=0)
        mnreportes.add_command(label='Tabla de Errores', command=self.tblerrores_click)
        mnreportes.add_command(label='Tabla de Simbolos', command=self.tblsimbolos_click)
        mnreportes.add_command(label='AST', command=self.ast_click)
        mnreportes.add_command(label='Reporte Gramatical', command=self.repDin_click)
        menu.add_cascade(label='Reportes', menu=mnreportes)
        self.window.config(menu=menu)

        ##############################################BOTONES####################################
        
        #img2 = PhotoImage(file='img/icons/AnalyzeMP.png')
        btnanalizar = Button(self.window , bg="#6a8d92",height=35, width=40, command=self.btnanalizar_click)
        btnanalizar.place(x=20,y=4)

       # img3 = PhotoImage(file='img/icons/play32.png')
        btnejecutar = Button(self.window , bg="#6a8d92",height=35, width=40,command=self.btnejecutar_click)
        btnejecutar.place(x=115,y=5)

       # img4 = PhotoImage(file='img/icons/op.png')
        btnoptimizar = Button(self.window, bg="#6a8d92",height=35, width=40,command=self.btnoptimizar_click)
        btnoptimizar.place(x=200,y=5)

        ##############################################PESTAÑAS####################################
        self.tab = ttk.Notebook(self.window)
        self.tab.pack(fill='both',padx=20, pady=[50,20])
        self.tab_frame =[]
        self.txtentrada =[]
        self.txtsalida =[]
        self.crear_tab("","Nuevo.sql")
        
        lblentrada= Label(self.window,text="Archivo de Entrada:",height=1, width=15,bg='#80b192')
        lblentrada.place(x=20,y=80)
        lblsalida= Label(self.window,text="Consola de Salida:",height=1, width=15,bg='#80b192')
        lblsalida.place(x=20,y=350)

        #redimensionar los elementos
        #self.window.bind('<Configure>',self.resizeEvent)

        #Objeto que almacena el Archivo
        self.file=""

        self.window.mainloop()
Ejemplo n.º 47
0
tabControl.add(tab2, text="Test Tone Demo")
tabControl.add(tab3, text="Meter Verify Demo")
tabControl.add(tab4, text="Plot Process Variables")
tabControl.pack(expand=1, fill="both")

#=============================================
# Create Menu
#=============================================
menuBar = Menu(win)
win.config(menu=menuBar)

fileMenu = Menu(menuBar, tearoff=0)
fileMenu.add_command(label="New")
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command=_quit)
menuBar.add_cascade(label="Status", menu=fileMenu)

helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label="Demo.exe Overview")
helpMenu.add_command(label="USB to 232 Converter Tip")
helpMenu.add_command(label="Setting Up Demo Stands")
helpMenu.add_command(label="SMV Overview")
helpMenu.add_command(label="Useful SMV Tip")
helpMenu.add_command(label="SMV & Prolink General Information")
helpMenu.add_command(label="Resetting Factory Baselines")
helpMenu.add_separator()
helpMenu.add_command(label="About Demo.exe")
menuBar.add_cascade(label="Help", menu=helpMenu)

#=============================================
# CREATE OBJECTS IN TAB1: CONNECT TO METERS
Ejemplo n.º 48
0
    def createWidgets(self):    
        # Tab Control introduced here --------------------------------------
        tabControl = ttk.Notebook(self.win)     # Create Tab Control
        
        tab1 = ttk.Frame(tabControl)            # Create a tab 
        tabControl.add(tab1, text='MCU')      # Add the tab
        
        tab2 = ttk.Frame(tabControl)            # Add a second tab
        tabControl.add(tab2, text='DSP')      # Make second tab visible
        
        tabControl.pack(expand=1, fill="both")  # Pack to make visible
        # ~ Tab Control introduced here -----------------------------------------
        
        # We are creating a container frame to hold all other widgets
        self.monty = ttk.LabelFrame(tab1, text=' Monty Python ')
        self.monty.grid(column=0, row=0, padx=8, pady=4)        
        
        # Changing our Label
        ttk.Label(self.monty, text="Enter a name:").grid(column=0, row=0, sticky='W')
   
        # Adding a Textbox Entry widget
        self.name = tk.StringVar()
        nameEntered = ttk.Entry(self.monty, width=24, textvariable=self.name)
        nameEntered.grid(column=0, row=1, sticky='W')     
        nameEntered.delete(0, tk.END)
        nameEntered.insert(0, '< default name >') 
        
        # Adding a Button
        self.action = ttk.Button(self.monty, text="Click Me!", command=self.clickMe)   
        self.action.grid(column=2, row=1)
        
        ttk.Label(self.monty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        numberChosen = ttk.Combobox(self.monty, width=14, textvariable=number)
        numberChosen['values'] = (1, 2, 4, 42, 100)
        numberChosen.grid(column=1, row=1)
        numberChosen.current(0)
             
        # Adding a Spinbox widget using a set of values
        self.spin = Spinbox(self.monty, values=(10, 20, 40, 420, 1000), width=5, bd=8, command=self._spin) 
        self.spin.grid(column=0, row=2, sticky='W')
                  
        # Using a scrolled Text control    
        scrolW  = 40; scrolH  =  10
        self.scr = scrolledtext.ScrolledText(self.monty, width=scrolW, height=scrolH, wrap=tk.WORD)
        self.scr.grid(column=0, row=3, sticky='WE', columnspan=3)
               
        # Tab Control 2 refactoring  ---------------------------------------------------
        # We are creating a container frame to hold all other widgets -- Tab2
        self.monty2 = ttk.LabelFrame(tab2, text=' The Snake ')
        self.monty2.grid(column=0, row=0, padx=8, pady=4)
        
        # Creating three checkbuttons
        chVarDis = tk.IntVar()
        check1 = tk.Checkbutton(self.monty2, text="Disabled", variable=chVarDis, state='disabled')
        check1.select()
        check1.grid(column=0, row=0, sticky=tk.W)                 
        
        self.chVarUn = tk.IntVar()
        self.check2 = tk.Checkbutton(self.monty2, text="UnChecked", variable=self.chVarUn)
        self.check2.deselect()
        self.check2.grid(column=1, row=0, sticky=tk.W )                  
         
        self.chVarEn = tk.IntVar()
        self.check3 = tk.Checkbutton(self.monty2, text="Toggle", variable=self.chVarEn)
        self.check3.deselect()
        self.check3.grid(column=2, row=0, sticky=tk.W)                 
     
        # trace the state of the two checkbuttons
        self.chVarUn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())    
        self.chVarEn.trace('w', lambda unused0, unused1, unused2 : self.checkCallback())   
        # ~ Tab Control 2 refactoring  -----------------------------------------
        
        # Radiobutton list
        colors = ["Blue", "Gold", "Red"]
        
        self.radVar = tk.IntVar()
        
        # Selecting a non-existing index value for radVar
        self.radVar.set(99)    
        
        # Creating all three Radiobutton widgets within one loop
        for col in range(3):
            curRad = 'rad' + str(col)  
            curRad = tk.Radiobutton(self.monty2, text=colors[col], variable=self.radVar, value=col, command=self.radCall)
            curRad.grid(column=col, row=6, sticky=tk.W, columnspan=3)
            # And now adding tooltips
            tt.createToolTip(curRad, 'This is a Radiobutton control.')
            
        # Create a container to hold labels
        labelsFrame = ttk.LabelFrame(self.monty2, text=' Labels in a Frame ')
        labelsFrame.grid(column=0, row=7)
         
        # Place labels into the container element - vertically
        ttk.Label(labelsFrame, text="Label1").grid(column=0, row=0)
        ttk.Label(labelsFrame, text="Label2").grid(column=0, row=1)
        
        # Add some space around each label
        for child in labelsFrame.winfo_children(): 
            child.grid_configure(padx=8)
        
        # Create Manage Files Frame ------------------------------------------------
        mngFilesFrame = ttk.LabelFrame(tab2, text=' Manage Files: ')
        mngFilesFrame.grid(column=0, row=1, sticky='WE', padx=10, pady=5)
        
        # Button Callback
        def getFileName():
            print('Callback getFileName')
            fDir  = path.dirname(__file__)
            fName = fd.askopenfilename(parent=self.win, initialdir=fDir)
            print(fName)
            self.fileEntry.config(state='enabled')
            self.fileEntry.delete(0, tk.END)
            self.fileEntry.insert(0, fName)
            
            if len(fName) > self.entryLen:
                self.fileEntry.config(width=len(fName) + 3)
                        
        # Add Widgets to Manage Files Frame
        lb = ttk.Button(mngFilesFrame, text="Browse to File...", command=getFileName)     
        lb.grid(column=0, row=0, sticky=tk.W) 
        
        #-----------------------------------------------------        
        file = tk.StringVar()
        self.entryLen = scrolW - 4
        self.fileEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=file)
        self.fileEntry.grid(column=1, row=0, sticky=tk.W)
              
        #-----------------------------------------------------
        logDir = tk.StringVar()
        self.netwEntry = ttk.Entry(mngFilesFrame, width=self.entryLen, textvariable=logDir)
        self.netwEntry.grid(column=1, row=1, sticky=tk.W) 

        
        def copyFile():
            import shutil   
            src = self.fileEntry.get()
            file = src.split('/')[-1]  
            dst = self.netwEntry.get() + '\\'+ file
            try:
                shutil.copy(src, dst)   
                mBox.showinfo('Copy File to Network', 'Succes: File copied.')     
            except FileNotFoundError as err:
                mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(err))
            except Exception as ex:
                mBox.showerror('Copy File to Network', '*** Failed to copy file! ***\n\n' + str(ex))   
        
        cb = ttk.Button(mngFilesFrame, text="Copy File To :   ", command=copyFile)     
        cb.grid(column=0, row=1, sticky=tk.E) 
                
        # Add some space around each label
        for child in mngFilesFrame.winfo_children(): 
            child.grid_configure(padx=6, pady=6)
                    

        # Creating a Menu Bar ==========================================================
        menuBar = Menu(tab1)
        self.win.config(menu=menuBar)
        
        # Add menu items
        fileMenu = Menu(menuBar, tearoff=0)
        fileMenu.add_command(label="New")
        fileMenu.add_separator()
        fileMenu.add_command(label="Exit", command=self._quit)
        menuBar.add_cascade(label="File", menu=fileMenu)
        
        # Add another Menu to the Menu Bar and an item
        helpMenu = Menu(menuBar, tearoff=0)
        helpMenu.add_command(label="About")
        menuBar.add_cascade(label="Help", menu=helpMenu)
        
        # Change the main windows icon
        self.win.iconbitmap( fDir +"\\pyc.ico")
        
        # Using tkinter Variable Classes
        strData = tk.StringVar()
        strData.set('StringVar')
        
        # It is not necessary to create a tk.StringVar() 
        strData = tk.StringVar()
        strData = self.spin.get()
        
        # Place cursor into name Entry
        # Set focus to Tab 1           
        tabControl.select(0)      
      
        # Add a Tooltip to the Spinbox
        tt.createToolTip(self.spin, 'This is a Spin control.')         
        
        # Add Tooltips to more widgets
        tt.createToolTip(nameEntered, 'This is an Entry control.')  
        tt.createToolTip(self.action, 'This is a Button control.')                      
        tt.createToolTip(self.scr,    'This is a ScrolledText control.')   
                      command=radCall)
rad2.grid(column=1, row=5, sticky=tk.W, columnspan=3)

rad3 = tk.Radiobutton(win,
                      text=COLOR3,
                      variable=radVar,
                      value=3,
                      command=radCall)
rad3.grid(column=2, row=5, sticky=tk.W, columnspan=3)
#using a scolled text context
scrolW = 50  # definig scroll text height and width
scrolH = 2
src = scrolledtext.ScrolledText(
    win, width=scrolW, height=scrolH,
    wrap=tk.WORD)  #wrap=tk.word by sending a wrap property totk.word
src.grid(column=0, columnspan=3)

menuBar = Menu(win)
win.config(menu=menuBar)
fileMenu = Menu(menuBar, tearoff=0)

fileMenu.add_command(label="start")
#  fileMenu.add_command(label="Exit")
#fileMenu.add_separator()
fileMenu.add_cascade(label="file", menu=fileMenu)
nameEntered.focus()
#place cursor into name entry
#src.focus()
#action.configure(state="disabeled")
win.mainloop()
Ejemplo n.º 50
0
    exit()


# Adding a title
win.title('Basic GUI')

# Creating a Menu bar:
menuBar = Menu()
win.config(menu=menuBar)

# Add menu Items:
fileMenu = Menu(menuBar, tearoff=0)
fileMenu.add_command(label='New')
fileMenu.add_separator()
fileMenu.add_command(label='Exit', command=quit)
menuBar.add_cascade(label='File', menu=fileMenu)

# Adding another menu
helpMenu = Menu(menuBar, tearoff=0)
helpMenu.add_command(label='About')
menuBar.add_cascade(label='Help', menu=helpMenu)

# Tab control:
tabControl = ttk.Notebook(win)  # Create a tab control

tab1 = ttk.Frame(tabControl)  # Crating first tab
tabControl.add(tab1, text='Tab 1')

tab2 = ttk.Frame(tabControl)
tabControl.add(tab2, text='Tab 2')
Ejemplo n.º 51
0
    def __init__(self, parent, mainframe):
        ttk.Frame.__init__(self, parent)
        self.mainframe = mainframe
        self.mainframe.title("网络测试(NetworkTest)")

        # 菜单栏
        self.mainframe.option_add('*tearOff', FALSE)
        menubar = Menu(self.mainframe)
        self.mainframe['menu'] = menubar
        menu_tools = Menu(menubar)
        menu_help = Menu(menubar)
        menubar.add_cascade(menu=menu_tools, label='工具库(Tools)')
        menubar.add_cascade(menu=menu_help, label='帮助(H)')
        menu_tools.add_command(label='IP地址测试(IP Test)',
                               command=lambda: mainframe.show_frame("StartPage"))
        menu_help.add_command(
            label='关于(About)', command=lambda: self.About_view())
        menu_tools.add_command(label='网段扫描(Network scanning)',
                               command=lambda: mainframe.show_frame("Network_scan"))
        menu_tools.add_command(label='自定义扫描(Auto Test)',
                               command=lambda: mainframe.show_frame("ALL_IPtest"))

        # 单个地址测试
        self.one_IPtest_img = ImageTk.PhotoImage(one_IPtest_image)
        self.IPtest = ttk.Label(self, text='IP地址测试',
                                image=self.one_IPtest_img, compound='left', font=TITLE_FONT, foreground='#1296db')

        self.Ip_start = ttk.Label(self, text='输入地址:', compound='left')
        self.one_iptest = StringVar()
        self.one_Ip_Entry = ttk.Entry(self, textvariable=self.one_iptest)
        self.one_scanning = ttk.Button(
            self, text="测试", command=lambda: self.One_IPtest())

        self.clear_views = ttk.Button(
            self, text="清空", command=lambda: self.cleane_view())

        self.Stop_test = ttk.Button(
            self, text="停止", command=lambda: self.Stop_Popen())

        self.choie_N = ttk.Label(self, text="选择测试次数:", compound='left')
        self.view_title = ttk.Label(self, text="测试结果", compound='left')

        # stop_popen
        self.stop_IPtest = StringVar()
        self.stop_IPtest.set('1')

        # 选择ping次数
        self.count_IPtest = StringVar()
        self.country_one = ttk.Combobox(self, textvariable=self.count_IPtest)
        self.country_one.bind('<< ComboboxSelected >>', function)
        self.country_one['values'] = ('2', '3', '4', '5', '∞')
        self.count_IPtest.set('4')

        # 结果显示
        VERTICAL = "vertical"
        self.Scanning_one = Listbox(self, height=20, width=100)
        self.ScanViews_one = ttk.Scrollbar(
            self, orient=VERTICAL, command=self.Scanning_one.yview)
        self.Scanning_one['yscrollcommand'] = self.ScanViews_one.set
        ttk.Sizegrip().grid(column=2, row=4, sticky="se")

        # 布局
        self.IPtest.grid(column=0, row=0, sticky="nwes", padx=5, pady=5)
        self.Ip_start.grid(column=1, row=1, sticky="nwes", padx=5, pady=5)
        self.one_Ip_Entry.grid(column=2, row=1, sticky="nwes", padx=5, pady=5)
        self.choie_N.grid(column=3, row=1, sticky="nwes", padx=5, pady=5)
        self.country_one.grid(column=4, row=1, sticky="nwes", padx=5, pady=5)
        self.one_scanning.grid(column=5, row=1, sticky="nwes", padx=5, pady=5)
        self.view_title.grid(column=1, row=2, sticky="nwes", padx=5, pady=5)
        self.ScanViews_one.grid(column=21, row=3, sticky="ns")
        self.Scanning_one.grid(
            column=1, row=3, sticky="nwes", columnspan=10, padx=5, pady=5)
        self.Stop_test.grid(column=1, row=11, sticky="nwes",
                            columnspan=1, rowspan=1, padx=5, pady=5)
        self.clear_views.grid(column=10, row=11, sticky="nwes",
                              columnspan=1, rowspan=1, padx=5, pady=5)
Ejemplo n.º 52
0
class OOP:
    def __init__(self):
        self.win = tk.Tk()
        self.win.resizable(0,0)    #这个是设置窗口不可缩放
        self.i18n = I18N('chi')
        self._createWidget()
        self.win.mainloop()
        
    def _quit(self):    #设置一个 menu 菜单项的激活函数
        self.win.quit()    #退出
        self.win.destroy()   #销毁
        exit()   #结束程序
    def _chi(self):
        self.win.quit()
        self.win.destroy()
        self.win = tk.Tk()
        self.win.resizable(0,0)    #这个是设置窗口不可缩放
        self.i18n = I18N('chi')
        self._createWidget()
        self.win.mainloop()
        
    def _jap(self):
        self.win.quit()
        self.win.destroy()
        self.win = tk.Tk()
        self.win.resizable(0,0)    #这个是设置窗口不可缩放
        self.i18n = I18N('jap')
        self._createWidget()
        self.win.mainloop()
        
    def _eng(self):
        self.win.quit()
        self.win.destroy()
        self.win = tk.Tk()
        self.win.resizable(0,0)    #这个是设置窗口不可缩放
        self.i18n = I18N('eng')
        self._createWidget()
        self.win.mainloop()
        
    def _getIptFileName(self):
        fDir = os.path.join( os.path.dirname(__file__),'..\Input')
        fName = fd.askopenfilename(parent=self.inOutFrm,initialdir=fDir)
        fPath = path.dirname(fName)
        self.inEry.delete(0,tk.END)   
        self.inEry.insert(0,fName)   
        
    def _getOptFileName(self):
        fDir = os.path.join( os.path.dirname(__file__),'..\Output')  
        fName = fd.askdirectory(parent=self.inOutFrm,initialdir=fDir)
        fPath = path.dirname(fName)
        self.outEry.delete(0,tk.END)   
        self.outEry.insert(0,fName)  
         
    def _getEngineFile(self):
        fDir = os.path.join(r'C:\Program Files\Tesseract-OCR')
        fName = fd.askopenfilename(parent=self.inOutFrm,initialdir=fDir)
        fPath = path.dirname(fName)
        self.engEry.delete(0,tk.END)   
        self.engEry.insert(0,fName)   
        
    def _screenShot(self):
        iptFileName = screenShot.buttonCaptureClick(self.win)
        self.win.state('normal')
        self.inEry.delete(0,tk.END)   
        self.inEry.insert(0,iptFileName)  
    
    
    def _createTransThread(self):
        flag = self.radVar.get()
        run = Thread(target=img2text.img2text,args=(self.engEry.get(),self.inEry.get(),
                                              self.outEry.get(),self.scrTxt,self.radVar.get()))
        
        
        run.setDaemon(True)
        run.start()
        
    def _clean(self):
        if mBox.askyesno("百变小T", 
                               "确定清空文本预览里的内容吗?"):
        
            self.scrTxt.delete(1.0,tk.END)
    
    def _trans(self):
        self._createTransThread()
        
    def _flag(self):
        pass
    
    def _createWidget(self):
        self.menuBar = Menu(self.win)
        self.win.configure(menu=self.menuBar)
        self.win.title(self.i18n.title)
        self.win.iconbitmap(r'../app.ico')
        self.startMenu = Menu(self.menuBar,tearoff=0)
        # pop menus:
        self.I18NMenu = Menu(self.startMenu,tearoff=0)    # 这个是 Menu 中的 Menu 了,可以一直这样嵌套下去
        self.I18NMenu.add_command(label=self.i18n.labChi,command=self._chi)
        self.I18NMenu.add_command(label=self.i18n.labJap,command=self._jap)
        self.I18NMenu.add_command(label=self.i18n.labEng,command=self._eng)
        self.startMenu.add_cascade(label=self.i18n.labTrans,menu=self.I18NMenu)
        
        
        self.startMenu.add_command(label=self.i18n.labQuit,command=self._quit)
        self.menuBar.add_cascade(label=self.i18n.labStart,menu=self.startMenu)
        
        self.tabControl = ttk.Notebook(self.win)
        self.tab1 = ttk.Frame(self.tabControl)
        self.tab2 = ttk.Frame(self.tabControl)
        self.tab3 = ttk.Frame(self.tabControl)
        self.tab4 = ttk.Frame(self.tabControl)
        self.tabControl.add(self.tab1,text=self.i18n.labTab1)
        self.tabControl.add(self.tab2,text=self.i18n.labTab2)
        self.tabControl.add(self.tab3,text=self.i18n.labTab3)
        self.tabControl.add(self.tab4,text=self.i18n.labTab4)
        self.tabControl.pack(fill='both',expand=1)
        
        self.zhuo = ttk.Frame(self.tab1)
        self.zhuo.grid(column=0,row=0)
        
        # 文件管理栏目
        
        
        self.inOutFrm = ttk.Frame(self.zhuo)
        self.inOutFrm.grid(column=0,row=0,sticky='W')
        self.fDir = os.path.abspath(os.path.join( os.path.dirname(__file__),".."))
        # 引擎
        self.engine = ttk.Button(self.inOutFrm,text=self.i18n.engine,
                            command=self._getEngineFile)
        self.engine.grid(row=2,column=0)
        self.eng_value = tk.StringVar()
        self.eng_value.set(r'C:\Program Files\Tesseract-OCR\tesseract.exe')
        
        self.engEry = ttk.Entry(self.inOutFrm,width=60,textvariable=self.eng_value)
        self.engEry.grid(row=2,column=1)
        
        self.inBut = ttk.Button(self.inOutFrm,text=self.i18n.inBut,
                            command=self._getIptFileName)
        self.inBut.grid(column=0,row=0)
        self.inBut_value = tk.StringVar()
        self.inBut_value.set(self.fDir+r'\Input')
        self.inEry = ttk.Entry(self.inOutFrm,width=60,textvariable=self.inBut_value)
        self.inEry.grid(column=1,row=0)
        
        
        
        self.outBut = ttk.Button(self.inOutFrm,text=self.i18n.outBut,
                                 command=self._getOptFileName)
        self.outBut.grid(column=0,row=1)
        self.outBut_value = tk.StringVar()
        self.outBut_value.set(self.fDir+r'\Output')
        self.outEry = ttk.Entry(self.inOutFrm,width=60,textvariable=self.outBut_value)
        self.outEry.grid(column=1,row=1)
        
        for child in self.inOutFrm.winfo_children():
            child.grid_configure(padx=6,pady=6,sticky='W')
        
        #语言选项
                #语言选项
        self.langFrm = ttk.Frame(self.zhuo)
        self.langFrm.grid(column=0,row=1,sticky='W',pady=6)
                
        LANG = [self.i18n.lang_chi,self.i18n.lang_eng,self.i18n.lang_jap,self.i18n.lang_tra,self.i18n.lang_math]    #设置颜色
        VALUE = ['chi_sim','eng','jpn','chi_tra','equ']
        
        self.radVar = tk.StringVar()    #声明
        self.radVar.set('chi_sim')    #初始化值,如果不初始化,这某个圆框会被 默认 选中
        
        ttk.Label(self.langFrm,text=self.i18n.label_tab).grid(column=0,row=0)        
        for col in range(5):
            rad = 'Rad'+ str(col)    #这个用于设置 对象名
            self.rad = tk.Radiobutton(self.langFrm,variable=self.radVar,value=VALUE[col],text=LANG[col])
            #实例化一个圆框对象,设置变量为 radVar。被选中时,其值设置为 col。 设置 圆框后面的字符为 COLOR
            # 设置触发事件为 clickRadio 函数
            self.rad.grid(column=col+1,row=0,sticky=tk.W)    #设置位置,且左对齐
            
        for child in self.langFrm.winfo_children():
            child.grid_configure(padx=6,pady=6,sticky='W')
        
        
        
        #截图与转换按钮
        self.butFrm = ttk.Frame(self.zhuo)
        self.butFrm.grid(column=0,row=2,sticky='W',pady=6)
        self.printScrBut = ttk.Button(self.butFrm,text=self.i18n.printScrBut,
                                   command=self._screenShot)
        self.printScrBut.grid(column=0,row=0)
        self.transBut = ttk.Button(self.butFrm,text=self.i18n.transBut,
                                   command=self._trans)
        self.transBut.grid(column=1,row=0)
#        self.iptBut = ttk.Button(self.butFrm,text=self.i18n.iptBut,
#                                   command=self._flag)
#        self.iptBut.grid(column=2,row=0)
        self.cleanBut = ttk.Button(self.butFrm,text=self.i18n.cleanBut,
                                   command=self._clean)
        self.cleanBut.grid(column=2,row=0)
        
        
        for child in self.butFrm.winfo_children():
            child.grid_configure(padx=6,pady=6,sticky='W')
        
        
        #滑动文字展示栏
        self.printOptFrm = ttk.LabelFrame(self.zhuo,text=self.i18n.printOptFrm)
        self.printOptFrm.grid(row=3,column=0,sticky='W')
        self.scrTxt = scrolledtext.ScrolledText(self.printOptFrm,height=20,width=70,wrap=tk.WORD)
        self.scrTxt.grid(row=0,column=0,sticky='W',padx=6,pady=6)
        
        self.tab2Widget = Tab2(self.tab2,self.i18n)
        self.tab3Widget = Tab3(self.tab3,self.i18n)
        self.tab4Widget = Tab4(self.tab4,self.i18n)
Ejemplo n.º 53
0
    def __init__(self, master):

        global canvas, ax, fig, fig1
        fig = Figure(figsize=(18, 8), dpi=100)
        ax = fig.add_subplot(gs[0, :])

        p = 150

        pos_x = 0.0
        pos_y = 0.0

        def init_stewart_platform():
            # Customize the view angle so it's easier to see that the scatter points lie
            # on the plane y=0
            ax4.set_xlim(-200, 200)
            ax4.set_ylim(-200, 200)
            ax4.set_zlim(0, 300)
            ax4.set_xlabel('X')
            ax4.set_ylabel('Y')
            ax4.set_zlabel('Z')

            update_stewart_platform()

            canvas.draw()

        def temel():
            print("temel61")

        def update_stewart_platform():
            platform_vertice = np.array([[-86, -100, p], [86, -100, p],
                                         [130, -25, p], [43, 125, p],
                                         [-43, 125, p], [-130, -25, p]])
            base_vertice = np.array([[-43, -125, 0], [43, -125, 0],
                                     [130, 25, 0], [86, 100, 0], [-86, 100, 0],
                                     [-130, 25, 0]])

            # ax4.scatter3D(platform_vertice[:, 0], platform_vertice[:, 1], platform_vertice[:, 2])

            platform = [[
                platform_vertice[0], platform_vertice[1], platform_vertice[2],
                platform_vertice[3], platform_vertice[4], platform_vertice[5]
            ]]
            base = [[
                base_vertice[0], base_vertice[1], base_vertice[2],
                base_vertice[3], base_vertice[4], base_vertice[5]
            ]]

            actuators = [[base_vertice[0], platform_vertice[0]],
                         [base_vertice[1], platform_vertice[1]],
                         [base_vertice[2], platform_vertice[2]],
                         [base_vertice[3], platform_vertice[3]],
                         [base_vertice[4], platform_vertice[4]],
                         [base_vertice[5], platform_vertice[5]]]

            ax4.add_collection3d(
                Poly3DCollection(platform,
                                 facecolors='gray',
                                 linewidths=1,
                                 edgecolors='black'))
            ax4.add_collection3d(
                Poly3DCollection(base,
                                 facecolors='gray',
                                 linewidths=1,
                                 edgecolors='black'))
            ax4.add_collection3d(
                Poly3DCollection(actuators, linewidths=3, edgecolors='black'))

            canvas.draw()

        def set_values(fileName):

            verts = []
            codes = []

            Path = mpath.Path
            codes.append(Path.MOVETO)

            x_data, y_data = np.loadtxt(fileName, delimiter=',', unpack=True)

            for x, y in zip(x_data, y_data):
                temp = (x, y)
                verts.append(temp)

            for x in range(len(x_data) - 1):
                codes.append(Path.LINETO)

            path = mpath.Path(verts, codes)

            patch = mpatches.PathPatch(path, facecolor='r', alpha=0.5)

            ax.add_patch(patch)

            myPlt1 = PathInteractor(patch)

            canvas.draw()
            fig.show()

        color = "#ffff00"

        canvas = FigureCanvasTkAgg(fig, master=root)  # A tk.DrawingArea.
        canvas.draw()
        canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.X)

        toolbar = NavigationToolbar2Tk(canvas, root)
        toolbar._message_label.config(background=color)
        toolbar.update()
        canvas.get_tk_widget().pack(side=tkinter.BOTTOM,
                                    fill=tkinter.BOTH,
                                    expand=1)

        ax4 = fig.add_subplot(gs[1:3, 1:4], projection='3d', aspect='equal')

        slider_x = ttk.Scale(master,
                             from_=-100,
                             to=100,
                             command=update_stewart_platform)
        slider_x.place(x=1500, y=600, width=100, height=50)

        init_stewart_platform()

        def _quit():
            if tkinter.messagebox.askokcancel("Quit", "Do you want to quit ?"):
                root.destroy()
                root.quit()  # stops mainloop

        def save_dat_file(filename):
            show_message("Save File", "File was saved succesfully")

        def openFile():
            filename = filedialog.askopenfilename(
                initialdir="/",
                title="Select file",
                filetypes=(("Dat Files", "*.dat"), ("All Files", "*.*")))
            if filename:
                set_values(filename)
                #readDatFile(filename)

        def saveFile():
            filename = filedialog.asksaveasfilename(
                initialdir="/",
                title="Select file",
                filetypes=(("Dat Files", "*.dat"), ("All Files", "*.*")))
            if filename:
                save_dat_file(filename)

        def show_message(myTitle, myMessage):
            tkinter.messagebox.showinfo(myTitle, myMessage)

        #test = Button(master=root, text="test", command=update_stewart_platform)
        #test.place(x=50, y=100)

        #openFile_button = ttk.Button(master=root, text="Open File", command=openFile)
        #openFile_button.place(x=50, y=150)

        menubar = Menu(root,
                       background='#000000',
                       foreground='white',
                       activebackground='#004c99',
                       activeforeground='white')

        # create a pulldown menu, and add it to the menu bar
        filemenu = Menu(menubar,
                        tearoff=0,
                        background='#ffffff',
                        foreground='black',
                        activebackground='#004c99',
                        activeforeground='black')
        filemenu.add_command(label="Open", command=openFile)
        #filemenu.add_command(label="Save", command=hello)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=_quit)
        menubar.add_cascade(label="File", menu=filemenu)

        # create more pulldown menus
        editmenu = Menu(menubar,
                        tearoff=0,
                        background='#ffffff',
                        foreground='black',
                        activebackground='#004c99',
                        activeforeground='black')
        #editmenu.add_command(label="Cut", command=hello)
        #editmenu.add_command(label="Copy", command=hello)
        #editmenu.add_command(label="Paste", command=hello)
        menubar.add_cascade(label="Edit", menu=editmenu)

        helpmenu = Menu(menubar,
                        tearoff=0,
                        background='#ffffff',
                        foreground='black',
                        activebackground='#004c99',
                        activeforeground='black')
        #helpmenu.add_command(label="About", command=hello)
        menubar.add_cascade(label="Help", menu=helpmenu)

        toolbar = Frame(root, bd=1, relief=RAISED)

        icons_png_file_path = "D:/LOCAL FILES/DOF_Motion_Editor/crystal-clear-icons-by-everaldo/png/"
        icons_icon_file_path = "D:/LOCAL FILES/DOF_Motion_Editor/crystal-clear-icons-by-everaldo/ico/"

        self.img = Image.open("C:/Users/DOF/Desktop/open-file-icon.png")
        eimg = ImageTk.PhotoImage(self.img)

        openFileButton = Button(toolbar,
                                image=eimg,
                                relief=FLAT,
                                command=openFile)
        openFileButton.image = eimg
        openFileButton.pack(side=LEFT, padx=2, pady=2)

        self.img1 = Image.open("C:/Users/DOF/Desktop/dat.png")
        eimg1 = ImageTk.PhotoImage(self.img1)

        saveFileButton = Button(toolbar,
                                image=eimg1,
                                relief=FLAT,
                                command=saveFile)
        saveFileButton.image = eimg1
        saveFileButton.pack(side=LEFT, padx=2, pady=2)

        self.img2 = Image.open("C:/Users/DOF/Desktop/exit.png")
        eimg2 = ImageTk.PhotoImage(self.img2)

        quitButton = Button(toolbar, image=eimg2, relief=FLAT, command=_quit)
        quitButton.image = eimg2
        quitButton.pack(side=LEFT, padx=2, pady=2)

        toolbar.pack(side=TOP, fill=X)

        # display the menu
        root.config(menu=menubar)
        root.protocol("WM_DELETE_WINDOW", _quit)
    def create_widgets(self):
        tabControl = ttk.Notebook(self.win)  # Create Tab Control

        tab1 = ttk.Frame(tabControl)  # Create a tab
        tabControl.add(tab1, text='Tab 1')  # Add the tab
        tab2 = ttk.Frame(tabControl)  # Add a second tab
        tabControl.add(tab2, text='Tab 2')  # Make second tab visible

        tabControl.pack(expand=1, fill="both")  # Pack to make visible

        # LabelFrame using tab1 as the parent
        mighty = ttk.LabelFrame(tab1, text=' Mighty Python ')
        mighty.grid(column=0, row=0, padx=8, pady=4)

        # Modify adding a Label using mighty as the parent instead of win
        a_label = ttk.Label(mighty, text="Enter a name:")
        a_label.grid(column=0, row=0, sticky='W')

        # Adding a Textbox Entry widget
        self.name = tk.StringVar()
        name_entered = ttk.Entry(mighty, width=12, textvariable=self.name)
        name_entered.grid(column=0, row=1, sticky='W')

        # Adding a Button
        self.action = ttk.Button(mighty,
                                 text="Click Me!",
                                 command=self.click_me)
        self.action.grid(column=2, row=1)

        ttk.Label(mighty, text="Choose a number:").grid(column=1, row=0)
        number = tk.StringVar()
        self.number_chosen = ttk.Combobox(mighty,
                                          width=12,
                                          textvariable=number,
                                          state='readonly')
        self.number_chosen['values'] = (1, 2, 4, 42, 100)
        self.number_chosen.grid(column=1, row=1)
        self.number_chosen.current(0)

        # Adding a Spinbox widget
        self.spin = Spinbox(mighty,
                            values=(1, 2, 4, 42, 100),
                            width=5,
                            bd=9,
                            command=self._spin)  # using range
        self.spin.grid(column=0, row=2)

        # Using a scrolled Text control
        scrol_w = 30
        scrol_h = 3
        self.scrol = scrolledtext.ScrolledText(mighty,
                                               width=scrol_w,
                                               height=scrol_h,
                                               wrap=tk.WORD)
        self.scrol.grid(column=0, row=3, sticky='WE', columnspan=3)

        # Tab Control 2 ----------------------------------------------------------------------
        # We are creating a container frame to hold all other widgets -- Tab2
        self.mighty2 = ttk.LabelFrame(tab2, text=' The Snake ')
        self.mighty2.grid(column=0, row=0, padx=8, pady=4)

        # Creating three checkbuttons
        chVarDis = tk.IntVar()
        check1 = tk.Checkbutton(self.mighty2,
                                text="Disabled",
                                variable=chVarDis,
                                state='disabled')
        check1.select()
        check1.grid(column=0, row=0, sticky=tk.W)

        chVarUn = tk.IntVar()
        check2 = tk.Checkbutton(self.mighty2,
                                text="UnChecked",
                                variable=chVarUn)
        check2.deselect()
        check2.grid(column=1, row=0, sticky=tk.W)

        chVarEn = tk.IntVar()
        check3 = tk.Checkbutton(self.mighty2, text="Enabled", variable=chVarEn)
        check3.deselect()
        check3.grid(column=2, row=0, sticky=tk.W)

        # trace the state of the two checkbuttons
        chVarUn.trace('w',
                      lambda unused0, unused1, unused2: self.checkCallback())
        chVarEn.trace('w',
                      lambda unused0, unused1, unused2: self.checkCallback())

        # First, we change our Radiobutton global variables into a list
        colors = ["Blue", "Gold", "Red"]

        # create three Radiobuttons using one variable
        self.radVar = tk.IntVar()

        # Next we are selecting a non-existing index value for radVar
        self.radVar.set(99)

        # Now we are creating all three Radiobutton widgets within one loop
        for col in range(3):
            curRad = tk.Radiobutton(self.mighty2,
                                    text=colors[col],
                                    variable=self.radVar,
                                    value=col,
                                    command=self.radCall)
            curRad.grid(column=col, row=1, sticky=tk.W)  # row=6

        # Add a Progressbar to Tab 2
        self.progress_bar = ttk.Progressbar(tab2,
                                            orient='horizontal',
                                            length=286,
                                            mode='determinate')
        self.progress_bar.grid(column=0, row=3, pady=2)

        # Create a container to hold buttons
        buttons_frame = ttk.LabelFrame(self.mighty2, text=' ProgressBar ')
        buttons_frame.grid(column=0, row=2, sticky='W', columnspan=2)

        # Add Buttons for Progressbar commands
        ttk.Button(buttons_frame,
                   text=" Run Progressbar   ",
                   command=self.run_progressbar).grid(column=0,
                                                      row=0,
                                                      sticky='W')
        ttk.Button(buttons_frame,
                   text=" Start Progressbar  ",
                   command=self.start_progressbar).grid(column=0,
                                                        row=1,
                                                        sticky='W')
        ttk.Button(buttons_frame,
                   text=" Stop immediately ",
                   command=self.stop_progressbar).grid(column=0,
                                                       row=2,
                                                       sticky='W')
        ttk.Button(buttons_frame,
                   text=" Stop after second ",
                   command=self.progressbar_stop_after).grid(column=0,
                                                             row=3,
                                                             sticky='W')

        for child in buttons_frame.winfo_children():
            child.grid_configure(padx=2, pady=2)

        for child in self.mighty2.winfo_children():
            child.grid_configure(padx=8, pady=2)

        # Creating a Menu Bar
        menu_bar = Menu(self.win)
        self.win.config(menu=menu_bar)

        # Add menu items
        file_menu = Menu(menu_bar, tearoff=0)
        file_menu.add_command(label="New")
        file_menu.add_separator()
        file_menu.add_command(label="Exit", command=self._quit)
        menu_bar.add_cascade(label="File", menu=file_menu)

        # Display a Message Box
        def _msgBox():
            msg.showinfo(
                'Python Message Info Box',
                'A Python GUI created using tkinter:\nThe year is 2017.')

        # Add another Menu to the Menu Bar and an item
        help_menu = Menu(menu_bar, tearoff=0)
        help_menu.add_command(
            label="About", command=_msgBox)  # display messagebox when clicked
        menu_bar.add_cascade(label="Help", menu=help_menu)

        # Change the main windows icon
        self.win.iconbitmap('pyc.ico')

        # It is not necessary to create a tk.StringVar()
        # strData = tk.StringVar()
        strData = self.spin.get()
        print("Spinbox value: " + strData)

        # call function
        self.usingGlobal()

        name_entered.focus()

def populatetable(cnmfe_file):
    tree = ttk.Treeview(root)
    tree["columns"] = ()
    #tree.column("one", width=150)
    #tree.column("two", width=100)
    #tree.heading("one", text="column A")
    #tree.heading("two", text="column B")
    tree.insert("", 0, text=cnmfe_file.split('/')[0])
    tree.pack()
    load_menu.add_command(label='display neurons')
    return ()


root = Tk()
root.title("NeuronViewer")
menu = Menu(root)
load_menu = Menu(menu)
load_menu.add_command(label='load output', command=loadCNMFEfile)
menu.add_cascade(label='File', menu=load_menu)
root.config(menu=menu)

root.mainloop()

#processed_video_file = loadFileDialog("select video file", ("select tiff stack", "*.tiff"))
#success, images = cv2.imreadmulti(processed_video_file)

#displayImageStackWindow(images, 'demixed_video')
#displayImageStackWindow(images, 'window_2')
radio2.grid(column=1, row=19, sticky=tk.W)

#Radio 3
radio3 = tk.Radiobutton(tab2, text="Casado", variable=opcion, value=3)
radio3.grid(column=2, row=19, sticky=tk.W)

texto11 = ttk.Label(tab2, text="Objetivo de la vida:").grid(column=0, row=4)
obj = scrolledtext.ScrolledText(tab2, width=30, height=3, wrap=tk.WORD)
obj.grid(column=0, columnspan=3)

#Boton
accion = ttk.Button(tab1, text="Imprimir datos", command=click)
accion.grid(column=5, row=20)
#Boton 2
accion = ttk.Button(tab2, text="Imprimir datos", command=click2)
accion.grid(column=5, row=20)
#Menu
barra_menu = Menu(ventana)
ventana.config(menu=barra_menu)
#Agregar opciones al menu
opciones_menu = Menu(barra_menu)
opciones_menu.add_command(label="Imprimir", command=click)
opciones_menu.add_command(label="Salir", command=funcion_salir)
barra_menu.add_cascade(label="Archivo", menu=opciones_menu)

#Menu ayuda, opcion 2
menu_ayuda = Menu(barra_menu, tearoff=0)
menu_ayuda.add_command(label="Acerca de", command=funcion_caja_mensaje)
barra_menu.add_cascade(label="Ayuda", menu=menu_ayuda)

ventana.mainloop()
Ejemplo n.º 57
0
class AccountManagerApps(tk.Tk):
    def __init__(self):

        tk.Tk.__init__(self)

        self.AM = AccountManager()

        self.create_widget()

    def quit_app(self):
        self.quit()
        self.destroy()
        quit()

    def create_widget(self):

        # metadata of the apps
        self.title("Account Manager Vers1.0")

        # header of the apps
        self.menu_bar = Menu(self)
        self.config(menu=self.menu_bar)

        # header File button
        self.file_menu = Menu(self)
        self.file_menu.add_command(label="Save", command=self.save_database)
        self.file_menu.add_command(label="Load", command=self.load_database)
        self.file_menu.add_command(label="Quit", command=self.quit_app)
        self.menu_bar.add_cascade(label="File", menu=self.file_menu)

        # header About button
        self.about_menu = Menu(self)
        self.about_menu.add_command(label="Help", command=self.about_app)
        self.menu_bar.add_cascade(label="About", menu=self.about_menu)

        # Top frame for choosing account to view
        self.viewacct_frame = ttk.LabelFrame(self, text="Account Manager")
        self.viewacct_frame.grid(row=1, column=0, columnspan=1, sticky="W")

        # Content for the top frame
        self.accounts = self.AM.get_accounts()

        self.viewacct_label = ttk.Label(self.viewacct_frame,
                                        text="View Account ")
        self.viewacct_label.grid(row=0, column=0, columnspan=1, stick="W")
        self.viewacct_field = tk.StringVar()
        self.viewacct_input = ttk.Combobox(self.viewacct_frame,
                                           width=30,
                                           textvariable=self.viewacct_field)
        self.viewacct_input.grid(row=0, column=1, columnspan=1, sticky="W")
        self.viewacct_input["values"] = self.accounts

        self.viewacct_button = ttk.Button(self.viewacct_frame,
                                          text="View",
                                          command=self.populate_tree)
        self.viewacct_button.grid(row=0, column=2, columnspan=1, sticky="W")

        # frame for the detailed transaction
        self.viewacct_frame = ttk.LabelFrame(self, text="Account Detail")
        self.viewacct_frame.grid(row=2, column=0, columnspan=1, sticky="W")

        self.view_account = None
        self.build_tree()

        self.editentry_button = ttk.Button(self.viewacct_frame,
                                           text="Edit",
                                           command=self.edit_entry)
        self.editentry_button.grid(row=1, column=6, columnspan=1, sticky="WE")

        self.removeentry_button = ttk.Button(self.viewacct_frame,
                                             text="Remove",
                                             command=self.remove_entry)
        self.removeentry_button.grid(row=1,
                                     column=7,
                                     columnspan=1,
                                     sticky="WE")

        # frame for the transaction editor
        self.editor_frame = ttk.LabelFrame(self, text="Transaction Editor")
        self.editor_frame.grid(row=3, column=0, columnspan=1, sticky="W")

        self.transid_label = ttk.Label(self.editor_frame,
                                       text="ID (for edit): ")
        self.transid_label.grid(row=0, column=0, columnspan=1, sticky="W")
        self.transid_field = tk.StringVar()
        self.transid_input = tk.Entry(self.editor_frame,
                                      width=23,
                                      textvariable=self.transid_field)
        self.transid_input.grid(row=0, column=1, columnspan=1, sticky="W")

        self.transdate_label = ttk.Label(self.editor_frame,
                                         text="Date (YYYY-MM-DD): ")
        self.transdate_label.grid(row=1, column=0, columnspan=1, sticky="W")
        self.transdate_field = tk.StringVar()
        self.transdate_input = tk.Entry(self.editor_frame,
                                        width=23,
                                        textvariable=self.transdate_field)
        self.transdate_input.grid(row=1, column=1, columnspan=1, sticky="W")

        self.transpurpose_label = ttk.Label(self.editor_frame,
                                            text=" Purpose: ")
        self.transpurpose_label.grid(row=1, column=2, columnspan=1, sticky="W")
        self.transpurpose_field = tk.StringVar()
        self.transpurpose_input = tk.Entry(
            self.editor_frame, width=23, textvariable=self.transpurpose_field)
        self.transpurpose_input.grid(row=1, column=3, columnspan=1, sticky="W")

        self.transfrom_label = ttk.Label(self.editor_frame, text="From: ")
        self.transfrom_label.grid(row=2, column=0, columnspan=1, sticky="W")
        self.transfrom_field = tk.StringVar()
        self.transfrom_input = ttk.Combobox(self.editor_frame,
                                            width=20,
                                            textvariable=self.transfrom_field)
        self.transfrom_input["values"] = self.accounts
        self.transfrom_input.grid(row=2, column=1, columnspan=1, sticky="W")

        self.transto_label = ttk.Label(self.editor_frame, text=" To: ")
        self.transto_label.grid(row=2, column=2, columnspan=1, sticky="W")
        self.transto_field = tk.StringVar()
        self.transto_input = ttk.Combobox(self.editor_frame,
                                          width=20,
                                          textvariable=self.transto_field)
        self.transto_input["values"] = self.accounts
        self.transto_input.grid(row=2, column=3, columnspan=1, sticky="W")

        self.transamount_label = ttk.Label(self.editor_frame, text="Amount: ")
        self.transamount_label.grid(row=3, column=0, columnspan=1, sticky="W")
        self.transamount_field = tk.StringVar()
        self.transamount_input = tk.Entry(self.editor_frame,
                                          width=23,
                                          textvariable=self.transamount_field)
        self.transamount_input.grid(row=3, column=1, columnspan=1, sticky="W")

        self.transremark_label = ttk.Label(self.editor_frame, text=" Remark: ")
        self.transremark_label.grid(row=3, column=2, columnspan=1, sticky="W")
        self.transremark_field = tk.StringVar()
        self.transremark_input = tk.Entry(self.editor_frame,
                                          width=23,
                                          textvariable=self.transremark_field)
        self.transremark_input.grid(row=3, column=3, columnspan=1, sticky="W")

        self.clearentry_button = ttk.Button(self.editor_frame,
                                            text="Clear",
                                            command=self.clear_entry)
        self.clearentry_button.grid(row=1, column=4, columnspan=1, sticky="WE")

        self.newentry_button = ttk.Button(self.editor_frame,
                                          text="Create",
                                          command=self.create_entry)
        self.newentry_button.grid(row=2, column=4, columnspan=1, sticky="WE")

        self.updateentry_button = ttk.Button(self.editor_frame,
                                             text="Update",
                                             command=self.update_entry)
        self.updateentry_button.grid(row=3,
                                     column=4,
                                     columnspan=1,
                                     sticky="WE")

    def save_database(self):

        filename = asksaveasfilename()

        if not filename.endswith(".csv"):
            filename += ".csv"

        self.AM.save_file(filename)

    def load_database(self):

        filename = askopenfilename()
        self.AM.load_file(filename)

        # refresh the system
        self.accounts = self.AM.get_accounts()
        self.view_account = None

        # update all refreshed values
        self.viewacct_input["values"] = self.accounts
        self.transfrom_input["values"] = self.accounts
        self.transto_input["values"] = self.accounts

        # clear all previous input
        self.viewacct_input.delete(0, tk.END)

        # clear tree
        for child in self.tree.get_children():
            self.tree.delete(child)

    def clear_entry(self):

        self.transid_input.delete(0, tk.END)
        self.transdate_input.delete(0, tk.END)
        self.transpurpose_input.delete(0, tk.END)
        self.transfrom_input.delete(0, tk.END)
        self.transto_input.delete(0, tk.END)
        self.transamount_input.delete(0, tk.END)
        self.transremark_input.delete(0, tk.END)

    def edit_entry(self):

        entry_IDs = self.tree.selection()
        print(entry_IDs)

        # only when one entry is selected the app
        # proceeds the edit procedure, otherwise
        # ignore the request
        if len(entry_IDs) == 0 or len(entry_IDs) > 1:
            return

        for entry_ID in entry_IDs:

            item = self.tree.item(entry_ID)['values']

            # list
            print(item)

        self.transid_field.set(item[0])
        self.transdate_field.set(item[1])
        self.transpurpose_field.set(item[2])
        self.transfrom_field.set(item[3])
        self.transto_field.set(item[4])
        self.transamount_field.set(item[5])
        self.transremark_field.set(item[7])

    def remove_entry(self):

        entry_IDs = self.tree.selection()
        print(entry_IDs)

        # only when one entry is selected the app
        # proceeds the edit procedure, otherwise
        # ignore the request
        if len(entry_IDs) == 0:
            return

        for entry_ID in entry_IDs:

            item = self.tree.item(entry_ID)['values']
            #self.tree.delete(entry_ID)
            self.AM.remove_entry(item)

        self.populate_tree("ID")

    def create_entry(self):

        input1 = self.transdate_field.get()
        input2 = self.transpurpose_field.get()
        input3 = self.transfrom_field.get()
        input4 = self.transto_field.get()
        input5 = self.transamount_field.get()
        input6 = self.transremark_field.get()

        input1 = datetime.datetime.strptime(input1, "%Y-%m-%d").date()
        input5 = float(input5)

        entry = [None, input1, input2, input3, input4, input5, input6]

        self.AM.create_entry(entry)

        self.populate_tree("ID")

    def update_entry(self):

        input0 = self.transid_field.get()
        input1 = self.transdate_field.get()
        input2 = self.transpurpose_field.get()
        input3 = self.transfrom_field.get()
        input4 = self.transto_field.get()
        input5 = self.transamount_field.get()
        input6 = self.transremark_field.get()

        input0 = int(input0)
        input1 = datetime.datetime.strptime(input1, "%Y-%m-%d").date()
        input5 = round(float(input5), 2)

        entry = (input0, input1, input2, input3, input4, input5, input6)

        self.AM.update_entry(entry)

        self.populate_tree("ID")

    def build_tree(self):

        columns = ["#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8"]
        self.tree = ttk.Treeview(self.viewacct_frame,
                                 columns=columns,
                                 show="headings")

        self.tree.heading("#1", text="ID", command=self.sort_database_by_id)
        self.tree.heading("#2",
                          text="Date",
                          command=self.sort_database_by_date)
        self.tree.heading("#3", text="Purpose")
        self.tree.heading("#4", text="From")
        self.tree.heading("#5", text="To")
        self.tree.heading("#6",
                          text="Amount",
                          command=self.sort_database_by_amount)
        self.tree.heading("#7", text="Total")
        self.tree.heading("#8", text="Remark")

        self.tree.column("#1", width=80, stretch=tk.NO)
        self.tree.column("#2", width=80, stretch=tk.NO)
        self.tree.column("#3", width=80, stretch=tk.NO)
        self.tree.column("#4", width=80, stretch=tk.NO)
        self.tree.column("#5", width=80, stretch=tk.NO)
        self.tree.column("#6", width=60, stretch=tk.NO)
        self.tree.column("#7", width=60, stretch=tk.NO)
        self.tree.column("#8", width=60, stretch=tk.NO)

        self.tree.grid(row=0, column=0, columnspan=8, sticky="we")

        self.tree_scrollbar = ttk.Scrollbar(self.viewacct_frame,
                                            orient=tk.VERTICAL,
                                            command=self.tree.yview)
        self.tree.configure(yscroll=self.tree_scrollbar.set)
        self.tree_scrollbar.grid(row=0, column=9, columnspan=1, sticky="ns")

    def sort_database_by_id(self):
        self.populate_tree("ID")

    def sort_database_by_date(self):
        self.populate_tree("Date")

    def sort_database_by_amount(self):
        self.populate_tree("Amount")

    def populate_tree(self, sort_key="ID"):

        for item in self.tree.get_children():
            self.tree.delete(item)

        self.view_account = self.viewacct_field.get()
        if self.view_account is None or self.view_account not in self.accounts:
            self.view_account = None
            return

        entries = self.AM.get_records(self.view_account, sort_key)
        for entry in entries:
            entry = list(entry)
            self.tree.insert('', tk.END, values=entry)

    def about_app(self):

        new_window = tk.Toplevel(self)
        new_window.title("About this app")

        message_text = "This app helps you to keep track of your financial record." + \
            "Let the app help manage your income and expediture by adding your transactions! " + \
            "The app helps you classify and visualize your cashflow to help you keep track " + \
            "of your current financial health. " + \
            "Developed by Shing Chi Leung at 14 Sep 2021."

        Message(new_window, text=message_text).pack()

        # keep the size of the help window
        new_window.resizable(False, False)
Ejemplo n.º 58
0
txt.focus()

chk_state = BooleanVar()
chk_state.set(False)
chk = Checkbutton(window, text='Choose', var=chk_state)
chk.grid(column=0, row=8)

rad1 = Radiobutton(window,text='First', value=1)
rad2 = Radiobutton(window,text='Second', value=2)
rad3 = Radiobutton(window,text='Third', value=3)
rad1.grid(column=0, row=9)
rad2.grid(column=0, row=10)
rad3.grid(column=0, row=11)

var =IntVar()
var.set(score)
spin = Spinbox(window, from_=0, to=100, width=5, textvariable=var)
spin.grid(column=0, row=12)


menu = Menu(window)
new_item = Menu(menu)
new_item.add_command(label='New')
menu.add_cascade(label='File', menu=new_item)
window.config(menu=menu)





window.mainloop()     # Keep the window open
Ejemplo n.º 59
0
scr = scrolledtext.ScrolledText(win,width = scrolW,height = scrolH)
scr.grid(column = 0,columnspan = 3)

labelsFrame = ttk.LabelFrame(win,text = 'Titles for you')
labelsFrame.grid(column = 1,row = 7)

ttk.Label(labelsFrame,text = 'Games').grid(column = 0,row = 0,padx = 20,pady = 20)
ttk.Label(labelsFrame,text = 'Movies').grid(column = 0,row = 1,padx = 20,pady = 20)
ttk.Label(labelsFrame,text = 'Music').grid(column = 0,row = 2,padx = 20,pady = 20)

menuBar = Menu(win)
win.configure(menu = menuBar)

def _quit():   #this is the quit function that enables us to come out of the.....
	win.quit()  # ..... GUI created by us
	win.destroy()
	exit()
	
fileMenu = Menu(menuBar)
fileMenu.add_command(label = 'New')
fileMenu.add_command(label = 'Exit',command = _quit)# calling to _quit() function
menuBar.add_cascade(menu = fileMenu,label = 'File')

def _msgBox():
	mBox.showinfo('Python Message Info Box','This is Python 3.7 :\nYour request is invalid')

helpMenu = Menu(menuBar)
helpMenu.add_command(label = 'About',command = _msgBox)
menuBar.add_cascade(menu = helpMenu,label = 'Help')

win.mainloop()
Ejemplo n.º 60
0
def open_file():
    file = open("./data/shape_rules.clp").read()
    if file != None:
        textPad.insert('1.0', file)


def save_file():
    f = open("./data/shape_rules.clp", "w+")
    data = str(textPad.get('1.0', END))
    print(data)
    f.write(data)
    f.close()
    root.destroy()


def exit():
    if messagebox.askokcancel("Quit", "Do you really want to quit?"):
        root.destroy()


menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
open_file()
menu.add_cascade(label="File", menu=filemenu)
filemenu.add_command(label="Save", command=save_file)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=exit)

textPad.pack()
root.mainloop()