Ejemplo n.º 1
0
    def _add_filename(self, frame, index, name, mode, option):
        if option:
            self.function[-1] = lambda v: [option, v]
        else:
            self.function[-1] = lambda v: [v]

        self.variables[-1] = StringVar()
        var = self.variables[-1]

        def set_name():
            if mode == "r":
                fn = tkFileDialog.askopenfilename(initialdir=".")
            else:
                fn = tkFileDialog.asksaveasfilename(initialdir=".")
            var.set(fn)

        label = Label(frame, text=name)
        label.grid(row=index, column=0, sticky="W", padx=10)

        field_button = Frame(frame)
        Grid.columnconfigure(field_button, 0, weight=1)

        field = Entry(field_button, textvariable=var)
        field.grid(row=0, column=0, sticky="WE")
        button = Button(field_button,
                        text="...",
                        command=set_name,
                        width=1,
                        padding=0)
        button.grid(row=0, column=1)

        field_button.grid(row=index, column=1, sticky="WE")
Ejemplo n.º 2
0
class CommAdd(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent        
        self.initUI()
        
    def initUI(self):
        # This should be different if running on Windows....
        content = pyperclip.paste()
        print content  
        self.entries_found = []

        self.parent.title("Add a new command card")
        self.style = Style()
        self.style.theme_use("default")        
        self.pack()
        
        self.new_title_label = Label(self, text="Title")
        self.new_title_label.grid(row=0, columnspan=2)
        self.new_title_entry = Entry(self, width=90)
        self.new_title_entry.grid(row=1, column=0)
        self.new_title_entry.focus()
        self.new_content_label = Label(self, text="Card")
        self.new_content_label.grid(row=2, columnspan=2)
        self.new_content_text = Text(self, width=110, height=34)
        self.new_content_text.insert(END, content)
        self.new_content_text.grid(row=3, columnspan=2)
        self.add_new_btn = Button(self, text="Add New Card", command=self.onAddNew)
        self.add_new_btn.grid(row=4)

    def onAddNew(self):

        pass
Ejemplo n.º 3
0
    def initUI(self):
        self.parent.title("simple")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(4, pad=3)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)

        cls = Button(self, text="Cls")
        cls.grid(row=1, column=0)

        quitbutton = Button(self, text="quit", command=self.parent.destroy)
        quitbutton.grid(row=4, column=0)

        self.var = IntVar()

        cb = Checkbutton(self,
                         text="show title",
                         variable=self.var,
                         command=self.onClick)
        cb.select()
        cb.grid(row=2, column=2)
        self.pack()
Ejemplo n.º 4
0
class cp_config_win(Toplevel):
    def __init__(self, parent):
        Toplevel.__init__(self)

        img = ImageTk.PhotoImage(file=os.path.join(os.path.dirname(__file__),
                                                   'Icons/LMS8001_PLLSim.png'))
        self.tk.call('wm', 'iconphoto', self._w, img)

        self.resizable(0, 0)
        self.parent = parent
        self.initUI()
        center_Window(self)
        self.protocol("WM_DELETE_WINDOW", self.on_Quit)

    def on_OK(self):
        self.on_Apply()
        self.on_Quit()

    def on_Apply(self):
        self.parent.cp_fc.set(float(self.entry_fc.get()) * 1.0e3)
        self.parent.cp_slope.set(float(self.entry_slope.get()))
        self.parent.pll.cp = lms8001_cp(fc=float(self.parent.cp_fc.get()),
                                        slope=float(
                                            self.parent.cp_slope.get()))
        self.parent.def_cp()

    def on_Quit(self):
        self.parent.cp_config_win = None
        self.destroy()

    def initUI(self):
        self.title('CP Noise Parameters')
        self.columnconfigure(0, pad=1)
        self.columnconfigure(1, pad=1)
        self.columnconfigure(2, pad=1)
        self.rowconfigure(0, pad=10)
        self.rowconfigure(1, pad=1)
        self.rowconfigure(2, pad=6)

        label1 = Label(self, text='Corner Frequency [kHz]')
        self.entry_fc = Entry(self, width=8)
        self.entry_fc.insert(END, str(self.parent.cp_fc.get() / 1.0e3))
        label1.grid(row=0, column=0, sticky=W)
        self.entry_fc.grid(row=0, column=1, sticky=W)

        label2 = Label(self, text='Noise slope [dB/dec]')
        self.entry_slope = Entry(self, width=8)
        self.entry_slope.insert(END, str(self.parent.cp_slope.get()))
        label2.grid(row=1, column=0, sticky=W)
        self.entry_slope.grid(row=1, column=1, sticky=W)

        button_OK = Button(self, text='OK', command=self.on_OK, width=10)
        button_Apply = Button(self,
                              text='Apply',
                              command=self.on_Apply,
                              width=10)
        button_Quit = Button(self, text='Quit', command=self.on_Quit, width=10)
        button_OK.grid(row=2, column=0, sticky=W + E + S)
        button_Apply.grid(row=2, column=1, sticky=W + E + S)
        button_Quit.grid(row=2, column=2, sticky=W + E + S)
Ejemplo n.º 5
0
    def initUI(self):
        self.parent.title("simple")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)
        ##        cls = Button(self, text="Cls")
        ##        cls.grid(row=1, column=0)
        label = Label(self, text="hello world")
        label.pack()

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

        quitbutton = Button(self, text="quit", command=self.parent.destroy)
        quitbutton.pack(side=RIGHT)

        self.pack(fill=BOTH, expand=.1)
Ejemplo n.º 6
0
class TabServices(Frame):

    def __init__(self, parent, txt=dict()):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # variables
        self.url_srv = StringVar(self,
                                 'http://suite.opengeo.org/geoserver/wfs?request=GetCapabilities')

        # widgets
        self.lb_url_srv = Label(self,
                                text='Web service URL GetCapabilities: ')
        self.ent_url_srv = Entry(self,
                                 width=75,
                                 textvariable=self.url_srv)
        self.btn_check_srv = Button(self, text="youhou")
        # widgets placement
        self.lb_url_srv.grid(row=0, column=0,
                             sticky="NSWE", padx=2, pady=2)
        self.ent_url_srv.grid(row=0, column=1,
                              sticky="NSWE", padx=2, pady=2)
        self.btn_check_srv.grid(row=0, column=2,
                                sticky="NSWE", padx=2, pady=2)
Ejemplo n.º 7
0
class Example(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent
        
        self.initUI()
        
    def initUI(self):
      
        self.parent.title("Please enter company name")
        
        Style().configure("TButton", padding=(0, 20, 0, 20), width=60)
        Style().configure("TLabel", padding=(3, 3, 3, 3))
        Style().configure("TEntry", padding=(0, 5, 0, 5))
        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)
        
        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)
        self.label = Label(self, text="Company Name")
        self.entry = Entry(self)
        self.entry.grid(row=0, columnspan=4, sticky=W+E)
        cls = Button(self, text="OK", command=self.quit)
        cls.grid(row=1, column=0)
        self.pack()
Ejemplo n.º 8
0
    def initUI(self):
      
        self.parent.title("Add Food")
        self.style = Style()
        self.style.theme_use("default")
        self.grid()

        l_name = Label(self.parent, text="Name")
        l_day = Label(self.parent, text="Day")
        l_month = Label(self.parent, text="Month")
        l_year = Label(self.parent, text="Year")

        l_name.grid(row=0, column=3)
        l_day.grid(row=0, column=0)
        l_month.grid(row=0, column=1)
        l_year.grid(row=0, column=2)

        days = []
        months = []
        years = []


        days.extend(range(1, 32))
        months.extend(range(1, 13))
        years.extend(range(2015, 2036))

        days = map(str, days)
        months = map(str, months)
        years = map(str, years)

        self.var_day = StringVar(self.parent)
        self.var_month = StringVar(self.parent)
        self.var_year = StringVar(self.parent)
        self.var_name = StringVar(self.parent)

        self.var_day.set(days[0])
        self.var_month.set(months[0])
        self.var_year.set(years[0])

        f_name = Entry(self.parent, textvariable=self.var_name)
        f_day = apply(OptionMenu, (self.parent, self.var_day) + tuple(days))
        f_month = apply(OptionMenu, (self.parent, self.var_month) +\
            tuple(months))
        f_year = apply(OptionMenu, (self.parent, self.var_year) +\
            tuple(years))

        f_name.grid(row=1, column=3)		
        f_day.grid(row=1, column=0)
        f_month.grid(row=1, column=1)
        f_year.grid(row=1, column=2)


        add_btn = Button(self.parent, text="Add Food", command=self.add_food)
        add_btn.grid(row=0, column=5)

        cancel_btn = Button(self.parent, text="Cancel",\
            command=self.cancel_food)
        cancel_btn.grid(row=1, column=5)
Ejemplo n.º 9
0
class MainFrame(Frame):    
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()    
              
    def initUI(self):
        self.parent.title("Driver Control Panel")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.label = Label(self, text="Bus Tracker - Driver", font=('Helvetica', '21'))
        self.label.grid(row=0, column=0)

        self.l = Label(self, text="Bus Line", font=('Helvetica', '18'))
        self.l.grid(row=1, column=0)
        self.e = Entry(self, font=('Helvetica', '18'))
        self.e.grid(row=2, column=0)

        self.l = Label(self, text="Direction", font=('Helvetica', '18'))
        self.l.grid(row=3, column=0)

        # add vertical space
        self.l = Label(self, text="", font=('Helvetica', '14'))
        self.l.grid(row=5, column=0)

        self.e = Entry(self, font=('Helvetica', '18'))
        self.e.grid(row=4, column=0)
        self.search = Button(self, text="Start")
        self.search.grid(row=6, column=0)   
        
        
        ######### used for debug ##########
        # add vertical space
        self.l2 = Label(self, text="", font=('Helvetica', '14'))
        self.l2.grid(row=5, column=0)
        
        self.turnOnBtn = Button(self, text="Turn On")
        self.turnOnBtn["command"] = self.turnOn 
        self.turnOnBtn.grid(row=6, column=0)    
        
        self.startBtn = Button(self, text="Start")
        self.startBtn["command"] = self.start 
        self.startBtn.grid(row=7, column=0)    
        
        self.turnOffBtn = Button(self, text="Turn Off")
        self.turnOffBtn["command"] = self.turnOff 
        self.turnOffBtn.grid(row=8, column=0)   
        
    def turnOn(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"turnOn", "busId":DRIVERID, "localIP":IP, "localPort":int(PORT)})
        
    def start(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"start", "route":ROUTNO, "direction":"north", "location":(0,0)})
        
    def turnOff(self):
        host.enqueue({"SM":"DRIVER_SM", "action":"turnOff"})    
	def add_file_browser(self, f, button_txt, init_txt , r, c, help_txt=''):
		b = Button(f,text=button_txt)
		b.grid(row=r, column=c, sticky=W+E)
		f_var = StringVar()
		f_var.set(init_txt)
		e = Entry(f, textvariable=f_var)
		e.grid(row=r, column=c+1)
		b.configure(command=lambda: self.browse_file(f_var, b))
		return f_var
Ejemplo n.º 11
0
 def _add_field(self, frame, index, name):
     self.variables[-1] = StringVar()
     label = Label(frame, text=name)
     label.grid(row=index, column=0, sticky="W", padx=10)
     field = Entry(frame)
     field.grid(row=index,
                column=1,
                sticky="WE",
                textvariable=self.variables[-1])
Ejemplo n.º 12
0
	def initUI(self, peakData, callback):

		self.parent.title("Calibrate energy to peaks")

		Style().configure("TButton", padding=(0, 5, 0, 5), 
			font='serif 10')

		self.columnconfigure(0, pad=3)
		self.columnconfigure(1, pad=3)
		self.columnconfigure(2, pad=3)
		self.columnconfigure(3, pad=3)

		rowNb = 0
		count = 0
		self.energyEntries = []
		self.energyErrEntries = []
		self.peakData = peakData
		self.callback = callback
		for rowNb in range(0,len(self.peakData)): #why not just iterate over fitData instead of over a range? Because we want to be sure of the ordering for adding energy levels later
			dataRow = self.peakData[rowNb]

			self.rowconfigure(count, pad=3)
			label = Label(self, text="Peak {0}".format(rowNb+1))
			label.grid(row=count, column=0, columnspan=4)
			count = count + 1

			self.rowconfigure(count, pad=3)
			label = Label(self, text='Peak')
			label.grid(row=count, column=0)
			label = Label(self, text=dataRow['Peak'])
			label.grid(row=count, column=1)
			label = Label(self, text='Err')
			label.grid(row=count, column=2)
			label = Label(self, text=dataRow['PeakErr'])
			label.grid(row=count, column=3)
			count = count + 1

			self.rowconfigure(count, pad=3)
			label = Label(self, text='Energy')
			label.grid(row=count, column=0)
			entryEnergy = Entry(self)
			entryEnergy.grid(row=count, column=1)
			label = Label(self, text='Err')
			label.grid(row=count, column=2)
			entryError = Entry(self)
			entryError.grid(row=count, column=3)
			count = count + 1

			self.energyEntries.append(entryEnergy)
			self.energyErrEntries.append(entryError)

		self.parent.bind("<Return>", self.buttonCallback)
		self.parent.bind("<KP_Enter>", self.buttonCallback)
		run = Button(self, text="Process calibration", command=self.buttonCallback)
		run.grid(row=count, column=0)
		count = count + 1
		self.pack()
Ejemplo n.º 13
0
 def add_file_browser(self, f, button_txt, init_txt, r, c, help_txt=''):
     b = Button(f, text=button_txt)
     b.grid(row=r, column=c, sticky=W + E)
     f_var = StringVar()
     f_var.set(init_txt)
     e = Entry(f, textvariable=f_var)
     e.grid(row=r, column=c + 1)
     b.configure(command=lambda: self.browse_file(f_var, b))
     return f_var
Ejemplo n.º 14
0
    def loginInit(self):
        self.parent.title("Password Keeper")
        Style().configure("Tlabel",font="Times")

        lbusr = Label(self,text="Master Username")
        lbusr.grid(row=0,column=0)
        lbps = Label(self,text="Master Password")
        lbps.grid(row=1,column=0)

        enusr = Entry(self)
        enusr.grid(row=0,column=1)
        enps = Entry(self)
        enps.grid(row=1,column=1)

        def login():
            credict = {}
            with open("cred.json","rb") as f:
                credict = json.load(f)

            for key in credict:
                if key == enusr.get() and credict[key] == enps.get():
                    switch()
                elif key != enusr.get() and credict[key] == enps.get():
                    tkMessageBox.showinfo(title=None,message="Wrong Username! Please Re-enter")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break
                elif key == enusr.get() and credict[key] != enps.get():
                    tkMessageBox.showinfo(title=None,message="Wrong password! Please Re-enter.")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break
                else:
                    tkMessageBox.showinfo(title=None,message="Username/Password combination is wrong! Please Re-enter")
                    enusr.delete(0, Tkinter.END)
                    enps.delete(0, Tkinter.END)
                    break

        def switch():
            self.parent.destroy()
            root = Tk()
            Primary(root,self.dict,self.enlist)
            root.mainloop()

        reg = Button(self,text="New User",command=self.register)
        reg.grid(row=2,column=0,sticky=W+E)
        lgn = Button(self,text="Login",command=login)
        lgn.grid(row=2,column=1,sticky=W+E)

        self.pack()
Ejemplo n.º 15
0
    def initUI(self):
      
        self.parent.title("TRAM")
        self.style = Style()
        self.style.theme_use("default")

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

        #Model Text
        self.t = Text(self, borderwidth=3, relief="sunken")
        self.t.config(font=("consolas", 12), undo=True, wrap='word')
        self.t.grid(row=0, column=0, padx=2, pady=2, sticky=(N, W, E, S))
        
        
        
        #Search Panel
        searchPanel = LabelFrame(self, text="Find your model")
        searchPanel.grid(row=0, column=1, padx=2, pady=2, sticky=N) 
        
        Label(searchPanel, text="Model name").grid(row=0, column=0, padx=2, pady=2, sticky=W)
        
        searchQueryEntry = Entry(searchPanel, textvariable=self.searchQuery)
        searchQueryEntry.grid(row=0, column=1, padx=2, pady=2, sticky=W)
        
        Label(searchPanel, text="Transformation").grid(row=1, column=0, padx=2, pady=2, sticky=W)
        preferredTransformation = StringVar()
        box = Combobox(searchPanel, textvariable=preferredTransformation, state='readonly')
        box['values'] = ('Any...', 'Object Change', 'Object Extension', 'Specialization', 'Functionality Extension', 'System Extension', 'Soft Simplification', 'Hard Simplification')
        box.current(0)
        box.grid(row=1, column=1, padx=2, pady=2, sticky=W)
        
        findButton = Button(searchPanel, text="Find", command = self.__findModels)
        findButton.grid(row=2, column=1, padx=2, pady=2, sticky=E)
        
        #Listbox with recommendations
        recommendationPanel = LabelFrame(self, text="Recommended models (transformations)")
        recommendationPanel.grid(row=0, column=1, padx=2, pady=2, sticky=(W,E,S))
        self.l = Listbox(recommendationPanel)
        self.l.pack(fill=BOTH, expand=1)
        
        #Button frame
        transformButtonPanel = Frame(recommendationPanel)
        transformButtonPanel.pack(fill=BOTH, expand=1)
        
        viewButton = Button(transformButtonPanel, text="View", command = self.__loadSelectedModel)
        viewButton.grid(row=1, column=0, padx=2, pady=2)
        
        transformButton = Button(transformButtonPanel, text="Transform", command = self.__transformModel)
        transformButton.grid(row=1, column=2, padx=2, pady=2)
Ejemplo n.º 16
0
	def initUI(self, parameterDict, callback, validate, undoCallback):

		self.parent.title("Choose parameters for fit")

		Style().configure("TButton", padding=(0, 5, 0, 5), 
			font='serif 10')

		self.columnconfigure(0, pad=3)
		self.columnconfigure(1, pad=3)

		count = 0
		entries = {}
		for key, value in parameterDict.iteritems():
			self.rowconfigure(count, pad=3)
			label = Label(self, text=key)
			label.grid(row=count, column=0)
			entry = Entry(self)
			entry.grid(row=count, column=1)
			entry.insert(0, value)
			entries[key] = entry
			count = count + 1

		def buttonCallback(*args): #the *args here is needed because the Button needs a function without an argument and the callback for function takes an event as argument
			try:
				newParameterDict = {}
				for key, value in entries.iteritems():
					newParameterDict[key] = value.get()
				self.parent.withdraw() #hide window
				feedback = callback(newParameterDict)
				if validate:
					if(askyesno("Validate", feedback,  default=YES)):
						self.parent.destroy() #clean up window
					else:
						undoCallback() #rollback changes done by callback
						self.parent.deiconify() #show the window again
				else:
					self.parent.withdraw()
					self.parent.destroy()
			except Exception as e:
				import traceback
				traceback.print_exc()
				self.parent.destroy()

		self.parent.bind("<Return>", buttonCallback)
		self.parent.bind("<KP_Enter>", buttonCallback)
		run = Button(self, text="Run fit", command=buttonCallback)
		run.grid(row=count, column=0)
		count = count + 1
		self.pack()
Ejemplo n.º 17
0
    def add_slice_bar(self, slice_frame):
        """Add a slice selection options to slice_frame.

        Returns
        -------
        this_slice_label_number : Label
            the field displaying the current slice number
        this_new_slice : Entry
            the field allowing the user to fill in a slice number
        new_value : int
            the initial slice number to be set

        """

        # Have a line displaying slice number
        _slice_label = Label(slice_frame, text='Slice displayed : ')
        _slice_label.grid(column=0, row=0, sticky=['w', 'e'])
        this_slice_label_number = Label(slice_frame)
        this_slice_label_number.grid(column=1, row=0,
                                     sticky=['w', 'e'])

        # Allow to change slice number
        _goto = Label(slice_frame, text=' - go to slice :')
        _goto.grid(column=2, row=0, sticky=['w', 'e'])

        this_new_slice = Entry(slice_frame, width=6)
        this_new_slice.bind('<Return>', self.goto_slice)
        this_new_slice.bind('<KP_Enter>', self.goto_slice)
        this_new_slice.grid(column=3, row=0, sticky=['w', 'e'])

        self.image_scale = (self.screen_width - 200) / 4

        # Allow to scroll through the slices
        self._slice_scroll = lsb.LinkedScrollBar(master=slice_frame,
                                                 command=self.disp_im,
                                                 minVal=self._get_min_slice(),
                                                 maxVal=self._get_max_slice(),
                                                 step=1,
                                                 orient='horizontal')
        self._slice_scroll.grid(column=0,
                                row=1,
                                columnspan=self.image_nb,
                                sticky=['e', 'w', 's'])


        self._slice_label_number = this_slice_label_number
        self._new_slice = this_new_slice
        self.reset_slice_scroll()
Ejemplo n.º 18
0
    def nuevoPais(self):
        t = Toplevel(self)
        t.wm_title("Pais")

        Label(t, text="Nombre").grid(row=0, column=1)
        E2 = Entry(t)
        E2.grid(row=1, column=1)

        button1 = Button(t, text="Cancelar", command=lambda: t.destroy())
        button2 = Button(t, text="Guardar", command=lambda: self.nuevaEntradaPais(E2.get(), t))
        button3 = Button(t, text="Borrar", command=lambda: self.BorrarPais(E2.get(), t))
        button3.config(state="disabled")

        button1.grid(row=2, column=0)
        button2.grid(row=2, column=1)
        button3.grid(row=2, column=2)
Ejemplo n.º 19
0
class NodeInfoDialog(tkSimpleDialog.Dialog):

    _label_var = None
    _theta_var = None

    def body(self, master):

        Label(master, text="Label:").grid(row=0, sticky=W)
        Label(master, text="Theta (deg):").grid(row=1, sticky=W)

        self._label_var = StringVar(master, value=NodeInfoDialog._label_var)
        self._theta_var = StringVar(master, value=NodeInfoDialog._theta_var)

        self.e1 = Entry(master, textvariable=self._label_var)
        self.e2 = Entry(master, textvariable=self._theta_var)

        self.e1.grid(row=0, column=1)
        self.e2.grid(row=1, column=1)
        return self.e1  # initial focus

    def validate(self):
        if not self.e2.get() == "":
            theta = float(self.e2.get())
            if theta < -360.0 or theta > 360.0:
                tkMessageBox.showerror(
                    "Invalid Theta value",
                    "Insert a value between -360° and 360°")
                self.e2.delete(0, 'end')
                return 0
            else:
                return 1
        else:
            return 1

    def apply(self):
        label = self.e1.get()
        theta = self.e2.get()

        self.result = label, theta

    @staticmethod
    def setLabelField(label):
        NodeInfoDialog._label_var = str(label)

    @staticmethod
    def setThetaField(theta):
        NodeInfoDialog._theta_var = str(theta)
Ejemplo n.º 20
0
    def __init__(self, master, sequencer):
        Frame.__init__(self, master)
        self.sequencer = sequencer

        self.control_label = Label(self, text="Control")

        self.start_button = Button(self, text="Start")
        self.stop_button = Button(self, text="Stop")

        self.start_button.config(command=self.sequencer.play)
        self.stop_button.config(command=self.sequencer.stop)

        self.control_label.pack()
        self.start_button.pack()
        self.stop_button.pack()

        Label(self, text='Tempo').pack()
        self.tempo_label = Label(self)
        self.tempo_label.pack()

        def set_tempo(v):
            tempo = float(v)
            self.sequencer.set_speed(tempo)
            self.tempo_label.config(text='%3.0f' % tempo)

        tempo_scale = Scale(self, from_=400, to=5, command=set_tempo, orient='vertical')
        tempo_scale.set(self.sequencer.speed)
        tempo_scale.pack()

        measure_control_frame = Frame(self)
        measure_control_frame.pack()

        self.measure_resolution = StringVar(measure_control_frame)
        self.measure_resolution.set(self.sequencer.measure_resolution)
        self.beats_per_measure = StringVar(measure_control_frame)
        self.beats_per_measure.set(self.sequencer.beats_per_measure)

        Label(measure_control_frame, text='Resolution').grid(row=0, column=0, sticky='E')
        measure_resolution_entry = Entry(measure_control_frame, textvariable=self.measure_resolution, width=3)
        measure_resolution_entry.grid(row=0, column=1)

        Label(measure_control_frame, text='Beats').grid(row=1, column=0, sticky='E')
        beats_per_measure_entry = Entry(measure_control_frame, textvariable=self.beats_per_measure, width=3)
        beats_per_measure_entry.grid(row=1, column=1)

        change_measure_update = Button(measure_control_frame, text='Update Measure', command=self.change_measures)
        change_measure_update.grid(row=2, columnspan=2)
Ejemplo n.º 21
0
    def editarParroquia(self):
        t = Toplevel(self)
        t.wm_title("Estudio")

        Label(t, text="Nombre").grid(row=0, column=1)
        E2 = Entry(t)
        E2.insert(END, self.selectorParroquial.get())
        E2.grid(row=1, column=1)

        nombreOld = self.selectorParroquial.get()

        button1 = Button(t, text="Cancelar", command=lambda: t.destroy())
        button2 = Button(t, text="Guardar", command=lambda: self.actualizarParroquia(nombreOld, E2.get(), t))
        button3 = Button(t, text="Borrar", command=lambda: self.BorrarParroquial(E2.get(), t))

        button1.grid(row=2, column=0)
        button2.grid(row=2, column=1)
        button3.grid(row=2, column=2)
Ejemplo n.º 22
0
class TabServices(Frame):
    def __init__(self, parent, txt=dict()):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # variables
        self.url_srv = StringVar(
            self,
            'http://suite.opengeo.org/geoserver/wfs?request=GetCapabilities')

        # widgets
        self.lb_url_srv = Label(self, text='Web service URL GetCapabilities: ')
        self.ent_url_srv = Entry(self, width=75, textvariable=self.url_srv)
        self.btn_check_srv = Button(self, text="youhou")
        # widgets placement
        self.lb_url_srv.grid(row=0, column=0, sticky="NSWE", padx=2, pady=2)
        self.ent_url_srv.grid(row=0, column=1, sticky="NSWE", padx=2, pady=2)
        self.btn_check_srv.grid(row=0, column=2, sticky="NSWE", padx=2, pady=2)
Ejemplo n.º 23
0
class DirectorySelector():
    def __init__(self, parent=None, text='Directory:', get_default=None):
        # NOTE: This class used to be a subclass of Frame, but it did not grid properly in the main window
        #Frame.__init__(self, parent)
        self.parent = parent
        self.label = Label(parent, text=text)
        self.directory = StringVar()
        on_change_cmd = parent.register(self.on_change)
        self.dir_entry = Entry(parent, textvariable=self.directory, validatecommand=on_change_cmd, validate='all')
        self.browse_btn = BrowseDirectoryButton(parent, entry=self)
        self.get_default = get_default
        self.notify_other = None

    def set_notify(self, notify_other):
        self.notify_other = notify_other

    def set_grid(self, row=0, padx=0):
        #self.grid(row=row)
        self.label.grid(row=row, column=0, sticky='e')
        self.dir_entry.grid(row=row, column=1, padx=padx, sticky='w')
        self.browse_btn.grid(row=row, column=2)

    def set_directory(self, directory):
        self.directory.set(directory)
        if self.notify_other != None:
            self.notify_other()
        #if self.parent != None:
            #self.parent.on_focus()

    def get_directory(self):
        directory = str(self.directory.get())
        if len(directory) > 0 and directory[len(directory)-1] != '/':
            directory = directory + '/'
        return directory

    def on_change(self):
        if self.get_default != None and self.get_directory() == '':
            self.set_directory(self.get_default())
        return True

    def notify(self):
        self.on_change()
Ejemplo n.º 24
0
	def initUI(self):
		
		self.parent.title("Simple FTP-Client")
		self.pack(fill=BOTH, expand=True)
	
		# self.parent.title("Buttons") 
				
		#frame2 = Frame(self)
		#frame2.pack(anchor=W,side=LEFT)
		#lbl2 = Label(frame2, text="Command Line", width=6)
		#lbl2.pack(fill=X,anchor=W,expand=True,padx=5, pady=5)        
		#txt2 = Text(frame2)
		#txt2.pack(fill=X,side=BOTTOM,pady=5, padx=5)           

		frame3 = Frame(self, width=400, height=500)
		frame3.pack(side=BOTTOM,anchor=NW)
		lbl3 = Label(frame3, text="Command Line", width=6)
		lbl3.pack(fill=X,anchor=NE,expand=True,padx=5, pady=5)        
		txt = Text(frame3)
		txt.pack(fill=BOTH,pady=5, padx=5)
	        wid = frame3.winfo_id()
		os.system('xterm -into %d -geometry 400x400 -sb &' % wid)
		
		     
		
		f1 = Frame(self)
		f1.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
		lb=Label(f1, text="Host:").grid(row=0, column=0)
		e1 = Entry(f1)
		e1.grid(row=0, column=1, padx=1)
		
		f2 = Frame(self)
		f2.pack(fill=X,side=LEFT, anchor=NW, padx=5, pady=10)
		lb2=Label(f2, text="Username:"******"Password:"******"Port:").grid(row=0, column=2)
		e4 = Entry(f4)
		e4.grid(row=0, column=3, padx=5)

		connectButton = Button(self, text="Connect", command=callback)
		connectButton.pack(expand=True,fill=X,side=LEFT, anchor=NW, padx=10, pady=10)
Ejemplo n.º 25
0
    def registerUI(self):
        self.parent.title("Password Keeper Registration")

        Style().configure("Tlabel",font="Courier")

        lbusr = Label(self,text="Enter a Master Username")
        lbusr.grid(row=0,column=0)
        lbps = Label(self,text="Enter a Master Password")
        lbps.grid(row=1,column=0)

        enusr = Entry(self)
        enusr.grid(row=0,column=1)
        enps = Entry(self)
        enps.grid(row=1,column=1)

        def reg():
            dict2 = {}
            if len(self.dict) == 0:
                self.dict[enusr.get()] = enps.get()
            else:
                dict2[enusr.get()] = enps.get()
                self.dict.update(dict2)

            print "Self.dict is now ",self.dict

            with open("cred.json","wb") as f:
                json.dump(self.dict,f)

            tkMessageBox.showinfo(title=None,message="You have registered!")

            """
            with open("cred.json","rb") as f:
                print f.read()
            """
            self.parent.destroy()

        reg = Button(self,text="Register",command=reg)
        reg.grid(row=2,column=0,sticky=W+E)

        self.pack()
    def initUI(self):
        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')
        
        for i in range(5):
            self.rowconfigure(i, pad=9)
            if i<4:
                self.columnconfigure(i, pad=3)
        
        matrix = {
                'Cls': [1, 0],
                'Back': [1, 1],
                'Close': [1, 3],
                '7': [2, 0],
                '8': [2, 1],
                '9': [2, 2],
                '/': [2, 3],
    
                '4': [3, 0],
                '5': [3, 1],
                '6': [3, 2],
                '*': [3, 3],
    
                '1': [4, 0],
                '2': [4, 1],
                '3': [4, 2],
                '-': [4, 3],
    
                '0': [5, 0],
                '.': [5, 1],
                '=': [5, 2],
                '+': [5, 3],
                }

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W+E)
        for k, v in matrix.items():
            v.append(Button(self, text=k))
            v[2].grid(row=v[0], column=v[1])
        self.matrix = matrix
        self.pack(padx=5, pady=5)
Ejemplo n.º 27
0
    def __draw_new_draft_window(self, parent):

        self.parent.title("New Draft")

        style = StringVar()
        style.set("Snake")

        opponent_label = Label(parent, text="Opponents")
        opponent_entry = Entry(parent, width=5)
        
        position_label = Label(parent, text="Draft Position")
        position_entry = Entry(parent, width=5)
        
        rounds_label = Label(parent, text="Number of Rounds")
        rounds_entry = Entry(parent, width=5)
        
        style_label = Label(parent, text="Draft Style")
        style_menu = OptionMenu(parent, style, "Snake", "Linear")
        
        def begin_draft():
            """
            initializes variables to control the flow of the draft
            calls the first window of the draft.
            """
            self.game.number_of_opponents = int(opponent_entry.get())
            self.game.draft_position = int(position_entry.get())
            self.game.number_of_rounds = int(rounds_entry.get())
            self.game.draft_style = style.get()
            
            self.game.opponents = []
            self.game.current_position = 1
            self.game.current_round = 1
            
            for x in xrange(self.game.number_of_opponents):
                self.game.opponents.append(Opponent.Opponent(x))

            if self.game.draft_position <= self.game.number_of_opponents + 1:
                MainUI(self.parent, self.game)
            else:
                tkMessageBox.showinfo("Error",
                                      "Draft position too high!\nYou would never get to pick a player"
                                      )

        def begin_button(event):
            begin_draft()

        ok_button = Button(parent, text="OK", command=begin_draft)
        self.parent.bind("<Return>", begin_button)
        
        opponent_label.grid(row=0, pady=5)
        opponent_entry.grid(row=0, column=1, pady=5)
        position_label.grid(row=1)
        position_entry.grid(row=1, column=1)
        rounds_label.grid(row=2, pady=5)
        rounds_entry.grid(row=2, column=1, pady=5, padx=5)
        style_label.grid(row=3)
        style_menu.grid(row=3, column=1)
        ok_button.grid(row=4, column=1, sticky="se", pady=5, padx=5)
Ejemplo n.º 28
0
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("simple")
        self.i0 = IntVar()
        self.nvt = IntVar()
        self.R = IntVar()

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(4, pad=3)

        #        i0
        self.entryi0 = Entry(self)
        self.entryi0.grid(row=0, column=1, sticky=W + E)
        cb = Checkbutton(self, text="i0", variable=self.i0)
        cb.select()
        cb.grid(row=1, column=1)
        cblabel = Label(self, text="use Value?")
        cblabel.grid(row=2, column=1)

        #        nvt
        self.entrynvt = Entry(self)
        self.entrynvt.grid(row=0, column=2, sticky=W + E)
        cb = Checkbutton(self, text="nVt", variable=self.nvt)
        cb.select()
        cb.grid(row=1, column=2)
        cblabel = Label(self, text="use Value?")
        cblabel.grid(row=2, column=2)

        #       R
        self.entryR = Entry(self)
        self.entryR.grid(row=0, column=3, sticky=W + E)
        cb = Checkbutton(self, text="R", variable=self.R)
        cb.select()
        cb.grid(row=1, column=3)
        cblabel = Label(self, text="use Value?")
        cblabel.grid(row=2, column=3)

        quitbutton = Button(self, text="quit", command=self.parent.destroy)
        quitbutton.grid(row=8, column=0)

        refreshbutton = Button(self, text="refresh", command=self.onClick)
        refreshbutton.grid(row=8, column=4)

        self.pack()

    def onClick(self):
        #        self.i0 = self.entryi0.get()
        print("i0:" + str(self.entryi0.get()))
Ejemplo n.º 29
0
class CommAdd(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent
        self.initUI()

    def initUI(self):
        # This should be different if running on Windows....
        content = pyperclip.paste()
        print content
        self.entries_found = []

        self.parent.title("Add a new command card")
        self.style = Style()
        self.style.theme_use("default")
        self.pack()

        self.new_title_label = Label(self, text="Title")
        self.new_title_label.grid(row=0, columnspan=2)
        self.new_title_entry = Entry(self, width=90)
        self.new_title_entry.grid(row=1, column=0)
        self.new_title_entry.focus()
        self.new_content_label = Label(self, text="Card")
        self.new_content_label.grid(row=2, columnspan=2)
        self.new_content_text = Text(self, width=110, height=34)
        self.new_content_text.insert(END, content)
        self.new_content_text.grid(row=3, columnspan=2)
        self.add_new_btn = Button(self,
                                  text="Add New Card",
                                  command=self.onAddNew)
        self.add_new_btn.grid(row=4)

    def onAddNew(self):

        pass
Ejemplo n.º 30
0
    def initUI(self):
        e = Entry(self)
        b1 = Button(self, text="1")
        b2 = Button(self, text="2")
        b3 = Button(self, text="3")
        b4 = Button(self, text="4")
        b5 = Button(self, text="5")
        b6 = Button(self, text="6")
        b7 = Button(self, text="7")
        b8 = Button(self, text="8")
        b9 = Button(self, text="9")

        e.grid(row=0, column=0, columnspan=4, sticky=W + E)
        b1.grid(row=1, column=0)
        b2.grid(row=1, column=1)
        b3.grid(row=1, column=2)
        b4.grid(row=2, column=0)
        b5.grid(row=2, column=1)
        b6.grid(row=2, column=2)
        b7.grid(row=3, column=0)
        b8.grid(row=3, column=1)
        b9.grid(row=3, column=2)

        self.pack()
Ejemplo n.º 31
0
    def initUI(self):
      
        self.parent.title("Catalog Analyzer")
        
        Style().configure("TButton", padding=(0, 5, 0, 5), 
            font='serif 10')
        
        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)
        
        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        ##  ENTRY  ###
        band1Label = Label(self, text='Band 1')
        band1Label.grid(row=0, column=0)
        band1Entry = Entry(self)
        band1Entry.grid(row=0, column=1)
        band2Label = Label(self, text='Band 2')
        band2Label.grid(row=0, column=2)
        band2Entry = Entry(self)
        band2Entry.grid(row=0, column=3 )
        band3Label = Label(self, text='Band 3')
        band3Label.grid(row=1, column=0)
        band3Entry = Entry(self)
        band3Entry.grid(row=1, column=1)
        band4Label = Label(self, text='Band 4')
        band4Label.grid(row=1, column=2)
        band4Entry = Entry(self)
        band4Entry.grid(row=1, column=3 )
        ##  BUTTONS  ###
        sizeMagButton = Button(self, text ="Size Magnitude", command = sizeMag)
        sizeMagButton.grid(row=2  , column = 0)
        
        hrButton = Button(self, text ="H-R Diagram", command = HR)
        hrButton.grid(row=2  , column = 1)
        
        colorColorButton = Button(self, text='Color Color', command=colorColor)
        colorColorButton.grid(row=2  , column = 2)
        

        
        self.pack()
Ejemplo n.º 32
0
class NewCustomerDialog(Dialog):
    def __init__(self, master, customers, refresh, edit=False, class_=None, relx=0.5, rely=0.3):
        if edit:
            self.title = "Edit Customer"
        else:
            self.title = "New Customer"

        self.refresh = refresh

        Dialog.__init__(self, master, self.title,
                        class_, relx, rely)
        self.customers = customers

        self.fname = StringVar()
        self.lname = StringVar()
        self.mname = StringVar()
        self.payment = StringVar()
        self.date = StringVar()
        self.close = False

        self.payment.set("Drop In")

        self.edit = edit

        self.new_customer_name = None

    def show(self, line=None):
        '''
        allows preset values
        '''
        self.setup() #base class setup

        self.frame = Frame(self.root)

        # blow out the field every time this is created
        if not self.edit: self.date.set(date.today().strftime("%m/%d/%Y"))
        
        ### dialog content        
        Label(self.frame, text="First Name: ").grid(row=0, sticky=W, ipady=2, pady=2)
        Label(self.frame, text="Middle Initial: ").grid(row=1, sticky=W, ipady=2, pady=2)
        Label(self.frame, text="Last Name: ").grid(row=2, sticky=W, ipady=2, pady=2)
        Label(self.frame, text="Customer Type: ").grid(row=3, sticky=W, ipady=2, pady=2)
        Label(self.frame, text="Date (mm/dd/yyyy): ").grid(row=4, sticky=W, ipady=2, pady=2)

        self.fname_en = Entry(self.frame, width=30, textvariable=self.fname)
        self.mname_en = Entry(self.frame, width=30, textvariable=self.mname)
        self.lname_en = Entry(self.frame, width=30, textvariable=self.lname)
        self.payment_cb = Combobox(self.frame, textvariable=self.payment, width=27,
                                   values=("Drop In", "Punch Card", "Monthly", "Inactive"))
        self.payment_cb.set("Drop In")
        self.date_en = Entry(self.frame, width=30, textvariable=self.date)

        Frame(self.frame, width=5).grid(row=0,column=1,sticky=W)
        
        self.fname_en.grid(row=0,column=2,columnspan=2,sticky=W)
        self.mname_en.grid(row=1,column=2,columnspan=2,sticky=W)
        self.lname_en.grid(row=2,column=2,columnspan=2,sticky=W)
        self.payment_cb.grid(row=3,column=2,columnspan=2,sticky=W)
        self.date_en.grid(row=4,column=2,columnspan=2,sticky=W)
        
        ### buttons
        Button(self.frame, text='Cancel', width=10,
               command=self.wm_delete_window).grid(row=5, column=2, sticky=W, padx=10, pady=3)
        Button(self.frame, text='Submit', width=10,
               command=self.add_customer).grid(row=5, column=3, sticky=W)
        self.frame.pack(padx=10, pady=10)

        self.root.bind("<Return>", self.add_customer)
        self.fname_en.focus_set()

        if line: #preset values
            self.fname.set(line[1])
            self.mname.set(line[2])
            self.lname.set(line[0])
            self.payment_cb.set(line[3])
            self.date.set(line[4].strftime("%m/%d/%Y"))
        
        ### enable from base class
        self.enable()

    def add_customer(self, event=None):
        # validate and show errors
        if self.fname.get() == '':
            showerror("Error!", "First name field blank!")
        elif self.lname.get() == '':
            showerror("Error!", "Last name field blank!")
        elif self.mname.get() == '':
            showerror("Error!", "Middle initial field blank!")
        elif self.payment.get() not in ("Drop In", "Punch Card", "Monthly", "Inactive"):
            showerror("Error!", "Incorect Customer type!")
        elif not re.compile(r'[01]?\d/[0123]?\d/[12]\d{1,3}').search(self.date.get()):
            showerror("Error!", "Bad entry for date, use format mm/dd/yyyy")
        else:
            self.close = True
            
            # do work
            old, row = self.customers.find(str(self.lname.get()).strip(), str(self.fname.get()).strip(),
                                           str(self.mname.get()).strip())
            new = [str(self.lname.get()).strip(), str(self.fname.get()).strip(), str(self.mname.get()).strip(),
                   str(self.payment.get()).strip(), datetime.strptime(self.date.get(), "%m/%d/%Y")]
            
            if not old and self.close:
                self.new_customer_name = ' '.join([new[1],new[2],new[0]])
                self.customers.add(new)
            elif self.close and not self.edit:
                var = IntVar()
                
                diag = AlreadyExistsDialog(self.root, new, old, var)
                diag.show()
                if var.get() == 0: # edit
                    self.close = False
                if var.get() == 1: # replace
                    self.customers.replace(row, new)
                    self.new_customer_name = ' '.join([new[1],new[2],new[0]])
                elif var.get() == 2: # add duplicate
                    self.customers.add(new)
                    self.new_customer_name = ' '.join([new[1],new[2],new[0]])
            else:
                self.customers.replace(row, new)

            if self.close:
                self.refresh()
                self.root.quit()
Ejemplo n.º 33
0
    def initUI(self):
        
        self.parent.title("FIND BLR COEFFICIENT VALUE")
        self.pack(fill=BOTH, expand=True)
        
        self.columnconfigure(0, weight=1)
        # self.rowconfigure(0, weight=1)
        # weight attibute is used to make them growable
        
        ###### GUI Control Variables ######
        self.LIMIT_L            = IntVar()
        self.LIMIT_H            = IntVar()
        self.PULSE_R            = IntVar()
        self.PULSE_L            = IntVar()
        self.pulse_height       = DoubleVar()
        self.hdf5_file          = StringVar()
        self.PMT                = IntVar()
        self.EVENT              = IntVar()
        self.amplitude_range    = DoubleVar()
        self.delta              = DoubleVar()
        self.noise_sigma        = DoubleVar()
        self.coeff              = DoubleVar()
        #self.DRAW               = BooleanVar()
        
        
        search = Image.open("next_logo.jpg")
        search_temp = search.resize((170, 200), Image.ANTIALIAS)
        search_aux = ImageTk.PhotoImage(search_temp)
        label1 = Label(self, image=search_aux)
        label1.image = search_aux
        label1.grid(row=0, column=0,
				columnspan=10, rowspan=10, sticky=E+W+S+N)
        
        
        self.hdf5_file.set("2052.h5.z")
        e1 = Entry(self, textvariable=self.hdf5_file, width=30)
        e1.grid(row=1,column=1, sticky=W, columnspan=5, pady=5)
        e1_label = Label(self, text="HDF5 file")
        e1_label.grid(row=0,column=1,sticky=W, columnspan=5, pady=5)        
               
        self.PMT.set("0")
        sb1 = Spinbox(self, from_=0, to=12, 
                      width=3, textvariable=self.PMT)
        sb1.grid(row=3,column=2, sticky=W)
        sb1_label = Label(self, text="PMT")
        sb1_label.grid(row=2,column=2, padx=0, sticky=W)
        
        self.EVENT.set("0")
        sb1 = Spinbox(self, from_=0, to=1000, 
                      width=5, textvariable=self.EVENT)
        sb1.grid(row=3,column=3, sticky=W)
        sb1_label = Label(self, text="EVENT")
        sb1_label.grid(row=2,column=3, padx=0, sticky=W)
        
        
        
        self.LIMIT_L.set("19000")
        sb1 = Spinbox(self, from_=0, to=100000, 
                      width=5, textvariable=self.LIMIT_L)
        sb1.grid(row=5,column=2, sticky=W)
        sb1_label = Label(self, text="ROI Start ")
        sb1_label.grid(row=4,column=2, padx=0, sticky=W)
        
        self.LIMIT_H.set("22500")
        sb1 = Spinbox(self, from_=0, to=100000, 
                      width=5, textvariable=self.LIMIT_H)
        sb1.grid(row=5,column=3, sticky=W)
        sb1_label = Label(self, text="ROI End ")
        sb1_label.grid(row=4,column=3, padx=0, sticky=W)
        
        
        
           
        self.PULSE_R.set("20142")
        sb1 = Spinbox(self, from_=0, to=100000, 
                      width=8, textvariable=self.PULSE_R)
        sb1.grid(row=5,column=4, sticky=E)
        sb1_label = Label(self, text=" Pulse Rise")
        sb1_label.grid(row=4,column=4, padx=0, sticky=E)
        
        self.PULSE_L.set("1200")
        sb1 = Spinbox(self, from_=0, to=5000, 
                      width=8, textvariable=self.PULSE_L)
        sb1.grid(row=5,column=5, sticky=E)
        sb1_label = Label(self, text=" Pulse Length")
        sb1_label.grid(row=4,column=5, padx=0, sticky=E)
        
        
        
        sb1_label = Label(self, text="  ")
        sb1_label.grid(row=2,column=7, padx=0, sticky=W)        
        sb1_label = Label(self, text="  ")
        sb1_label.grid(row=6,column=7, padx=0, sticky=W)
        
        
        self.pulse_height.set("545.5")
        sb1 = Entry(self, width=8, textvariable=self.pulse_height)
        sb1.grid(row=7,column=3, sticky=E)
        sb1_label = Label(self, text=" Amplitude")
        sb1_label.grid(row=6,column=3, padx=0, sticky=E)
        
        self.amplitude_range.set("2")
        sb1 = Entry(self, width=8, textvariable=self.amplitude_range)
        sb1.grid(row=7,column=4, sticky=E)
        sb1_label = Label(self, text=" Loop Range")
        sb1_label.grid(row=6,column=4, padx=0, sticky=E)
        
        self.delta.set("0.1")
        sb1 = Entry(self, width=8, textvariable=self.delta)
        sb1.grid(row=7,column=5, sticky=E)
        sb1_label = Label(self, text=" Loop Delta")
        sb1_label.grid(row=6,column=5, padx=0, sticky=E)
        
        self.noise_sigma.set("4")
        sb1 = Entry(self, width=3, textvariable=self.noise_sigma)
        sb1.grid(row=5,column=6, sticky=E)
        sb1_label = Label(self, text=" Noise Threshold")
        sb1_label.grid(row=4,column=6, padx=0, sticky=E)
        
        sb_coeff_label = Label(self, text= "Coefficient ")
        sb_coeff_label.grid(row=0,column=6, padx=0, sticky=E)
        self.sb_coeff = Label(self)
        self.sb_coeff.grid(row=1,column=6, padx=0, sticky=E)


        
        # MAIN BUTTONS
        obtn = Button(self, text="GO!!", command=self.find_C)
        obtn.grid(row=14, column=4, sticky=E, pady=10)
        
        cbtn = Button(self, text="Quit", command=self.quit)
        cbtn.grid(row=14, column=5, sticky=E, pady=10)
        
        hbtn = Button(self, text="Help", command=self.help_f)
        hbtn.grid(row=14, column=0, sticky=W, pady=10)
Ejemplo n.º 34
0
    def __init__(self, parent, txt=dict(), switcher=None):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # subframes
        self.FrOptProxy = Frame(self, name='settings_proxy')
        self.FrOptIsogeo = Frame(self, name='settings_isogeo')

        # options values
        self.opt_proxy = IntVar(self)  # proxy option
        self.opt_isogeo = IntVar(self)  # Isogeo option

        # Options form widgets
        caz_prox = Checkbutton(
            self,
            text=u'Proxy',
            variable=self.opt_proxy,
            command=lambda: switcher(self.opt_proxy, self.FrOptProxy))
        caz_isogeo = Checkbutton(
            self,
            text=u'Isogeo',
            variable=self.opt_isogeo,
            command=lambda: switcher(self.opt_isogeo, self.FrOptIsogeo))

        # positionning
        caz_prox.grid(row=0, column=0, sticky="NSWE", padx=2, pady=2)
        self.FrOptProxy.grid(row=0,
                             column=1,
                             columnspan=8,
                             sticky="NSWE",
                             padx=2,
                             pady=2,
                             rowspan=3)
        caz_isogeo.grid(row=3, column=0, sticky="NSWE", padx=2, pady=2)
        self.FrOptIsogeo.grid(row=3,
                              column=1,
                              columnspan=8,
                              sticky="NSWE",
                              padx=2,
                              pady=2,
                              rowspan=4)

        # ------------------------------------------------------------------------
        # proxy specific variables
        self.opt_ntlm = IntVar(self.FrOptProxy,
                               0)  # proxy NTLM protocol option
        self.prox_server = StringVar(self.FrOptProxy, 'proxy.server.com')
        self.prox_port = IntVar(self.FrOptProxy, 80)
        self.prox_user = StringVar(self.FrOptProxy, 'proxy_user')
        self.prox_pswd = StringVar(self.FrOptProxy, '****')

        # widgets
        self.prox_ent_H = Entry(self.FrOptProxy, textvariable=self.prox_server)
        self.prox_ent_P = Entry(self.FrOptProxy, textvariable=self.prox_port)
        self.prox_ent_M = Entry(self.FrOptProxy,
                                textvariable=self.prox_pswd,
                                show='*')

        self.prox_lb_H = Label(self.FrOptProxy,
                               text=txt.get('gui_prox_server', "Host"))
        self.prox_lb_P = Label(self.FrOptProxy,
                               text=txt.get('gui_port', "Port"))
        caz_ntlm = Checkbutton(self.FrOptProxy,
                               text=u'NTLM',
                               variable=self.opt_ntlm)
        self.prox_lb_M = Label(self.FrOptProxy,
                               text=txt.get('gui_mdp', "Password"))

        # proxy widgets position
        self.prox_lb_H.grid(row=1, column=0, sticky="NSEW", padx=2, pady=2)
        self.prox_ent_H.grid(row=1,
                             column=1,
                             columnspan=2,
                             sticky="NSEW",
                             padx=2,
                             pady=2)
        self.prox_lb_P.grid(row=1, column=2, sticky="NSEW", padx=2, pady=2)
        self.prox_ent_P.grid(row=1,
                             column=3,
                             columnspan=2,
                             sticky="NSEW",
                             padx=2,
                             pady=2)
        caz_ntlm.grid(row=2, column=0, sticky="NSEW", padx=2, pady=2)
        self.prox_lb_M.grid(row=2, column=1, sticky="NSEW", padx=2, pady=2)
        self.prox_ent_M.grid(row=2,
                             column=2,
                             columnspan=2,
                             sticky="NSEW",
                             padx=2,
                             pady=2)

        # ------------------------------------------------------------------------
        # Isogeo application variables
        self.isog_app_id = StringVar(self.FrOptIsogeo, 'application_id')
        self.isog_app_tk = StringVar(self.FrOptIsogeo, 'secret')

        # widgets
        isog_ent_id = Entry(self.FrOptIsogeo, textvariable=self.isog_app_id)
        isog_ent_tk = Entry(self.FrOptIsogeo, textvariable=self.isog_app_tk)

        isog_lb_id = Label(self.FrOptIsogeo, text="Application ID")
        isog_lb_tk = Label(self.FrOptIsogeo, text="Application secret")

        # Isogeo widgets position
        isog_lb_id.grid(row=1, column=1, sticky="NSEW", padx=2, pady=2)
        isog_ent_id.grid(row=1,
                         column=2,
                         columnspan=2,
                         sticky="NSEW",
                         padx=2,
                         pady=2)
        isog_lb_tk.grid(row=2, column=1, sticky="NSEW", padx=2, pady=2)
        isog_ent_tk.grid(row=2,
                         column=2,
                         columnspan=2,
                         sticky="NSEW",
                         padx=2,
                         pady=2)
Ejemplo n.º 35
0
Archivo: pySAD.py Proyecto: AlbMA/PySAD
    def initUI(self):

        self.initText()

        self.parent.title("PySAD")
        self.style = Style()
        self.style.theme_use("clam")

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

        barraLateral = Frame(self, borderwidth=1)
        barraLateral.pack(side=RIGHT, padx=5, pady=5)

        idiomaFrame = Frame(barraLateral, relief=FLAT)
        idiomaFrame.pack(side=TOP)

        self.espButton = Button(idiomaFrame,
                                text="es",
                                width=0,
                                command=lambda: self.updateText(0))
        self.espButton.grid(row=0, column=0)
        self.engButton = Button(idiomaFrame,
                                text="en",
                                width=0,
                                command=lambda: self.updateText(1))
        self.engButton.grid(row=0, column=1)

        self.updateText(0)

        editarFrame = Frame(barraLateral,
                            relief=RAISED,
                            borderwidth=1,
                            width=1000)
        editarFrame.pack(fill=BOTH, expand=1, side=TOP, padx=5, pady=5)

        self.tipoCurva = IntVar()

        tituloSelector = Label(editarFrame, textvariable=self.curTip)
        tituloSelector.grid(row=0, columnspan=2, padx=2, pady=4)
        Radiobutton(editarFrame,
                    textvariable=self.ArcSpi,
                    variable=self.tipoCurva,
                    value=1,
                    command=self.cambiaFormula,
                    width=17).grid(row=1, columnspan=2, sticky=W, padx=4)
        Radiobutton(editarFrame,
                    textvariable=self.LogSpi,
                    variable=self.tipoCurva,
                    value=2,
                    command=self.cambiaFormula).grid(row=2,
                                                     columnspan=2,
                                                     sticky=W,
                                                     padx=4)

        self.formulaLabel = Label(editarFrame)
        self.formulaLabel.grid(row=4, columnspan=2, pady=4)

        Label(editarFrame, textvariable=self.aaa).grid(row=5, column=0, pady=2)
        Label(editarFrame, textvariable=self.bbb).grid(row=6, column=0, pady=2)
        self.labelC = Label(editarFrame, textvariable=self.ccc)
        self.labelC.grid(row=7, column=0, pady=2)
        self.labelC.config(state=DISABLED)
        Label(editarFrame, textvariable=self.Lma).grid(row=8, column=0, pady=2)
        Label(editarFrame, textvariable=self.fre).grid(row=9, column=0, pady=2)

        parA = Entry(editarFrame, width=4, textvariable=self.a)
        parA.grid(row=5, column=1, sticky=W)

        parB = Entry(editarFrame, width=4, textvariable=self.b)
        parB.grid(row=6, column=1, sticky=W)

        self.parC = Entry(editarFrame, width=4, textvariable=self.c)
        self.parC.grid(row=7, column=1, sticky=W)
        self.parC.config(state=DISABLED)

        lMax = Entry(editarFrame, width=4, textvariable=self.lMax)
        lMax.grid(row=8, column=1, sticky=W)
        self.createToolTip(lMax, self.stringText['LmaToo'])

        frec = Entry(editarFrame, width=4, textvariable=self.frec)
        frec.grid(row=9, column=1, sticky=W)
        self.createToolTip(frec, self.stringText['FreToo'])

        self.espejar = IntVar()
        checkEspejar = Checkbutton(editarFrame,
                                   textvariable=self.Mir,
                                   variable=self.espejar,
                                   command=self.activarFuente)
        checkEspejar.grid(row=10, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(checkEspejar, self.stringText['MirToo'])

        self.fuente = IntVar()
        self.checkFuente = Checkbutton(editarFrame,
                                       textvariable=self.Sou,
                                       state=DISABLED,
                                       variable=self.fuente)
        self.checkFuente.grid(row=11, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(self.checkFuente, self.stringText['SouToo'])

        okButton = Button(editarFrame,
                          textvariable=self.Gen,
                          command=self.regraficar)
        okButton.grid(row=12, columnspan=2, pady=5)
        self.createToolTip(okButton, self.stringText['GenToo'])

        self.frame2 = Frame(self, borderwidth=1)
        self.frame2.pack(fill=BOTH, expand=1, side=LEFT, padx=5, pady=5)

        self.canvas = FigureCanvasTkAgg(self.f, master=self.frame2)
        self.canvas.get_tk_widget().pack(side=TOP,
                                         fill=BOTH,
                                         expand=1,
                                         padx=10,
                                         pady=10)

        frameGuardar = Frame(barraLateral, relief=FLAT, borderwidth=1)
        frameGuardar.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        icGuardar = PhotoImage(
            data=
            '''R0lGODlhEAAQAIABADMzM////yH5BAEKAAEALAAAAAAQABAAAAIlDI55wchvQJQOxontUktTbkHcSJZkGCao161N5U5SLNM1vZlOAQA7'''
        )
        saveButtonNEC = Button(frameGuardar,
                               text=self.stringText['NEC'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirFichero,
                               width=3)
        saveButtonNEC.image = icGuardar
        saveButtonNEC.grid(row=0, column=0, pady=2, padx=2, sticky=W)
        self.createToolTip(saveButtonNEC, self.stringText['NECToo'])

        saveButtonPDF = Button(frameGuardar,
                               text=self.stringText['PDF'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirPDF,
                               width=3)
        saveButtonPDF.image = icGuardar
        saveButtonPDF.grid(row=0, column=2, pady=2, padx=2, sticky=E)
        self.createToolTip(saveButtonPDF, self.stringText['PDFToo'])

        self.helpButton = Button(frameGuardar,
                                 text="?",
                                 command=self.mostrarAyuda,
                                 width=2)
        self.helpButton.grid(row=0, column=3, pady=2, padx=2, sticky=E)

        frame3 = Frame(barraLateral, relief=RAISED, borderwidth=1)
        frame3.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        Label(frame3, textvariable=self.lenlen).grid(row=1,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.radrad).grid(row=2,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.StringLongitud).grid(row=1,
                                                             column=1,
                                                             pady=4)
        Label(frame3, textvariable=self.StringRadio).grid(row=2,
                                                          column=1,
                                                          pady=4)
Ejemplo n.º 36
0
class Window(Frame):
    def __init__(self, parent, window_type):
        Frame.__init__(self, parent, msg = None)

        self.parent = parent
        if window_type == "main":
            self.initUI_main()
        if window_type == "err":
            self.initUI_err()

    def initUI_main(self):
        self.parent.title("Personal Helper")
        self.pack(fill=BOTH, expand=True)

        self.columnconfigure(0, weight=1)
        self.columnconfigure(7, weight=1)
        self.columnconfigure(5, pad=10)
        self.columnconfigure(3, pad=10)
        self.columnconfigure(1, weight=3)
        self.rowconfigure(0, weight=0)
        self.rowconfigure(5, weight=1)
        self.rowconfigure(5, pad=7)
        self.rowconfigure(6, pad=6)


        lbl = Label(self, text="Windows")
        lbl.grid(sticky=W+N, pady=4, padx=5)


        check_box = {"work": IntVar(),
                     "boost": IntVar()}

        check1 = Checkbutton(self, text="work-Mode", variable=check_box["work"])
        check1.grid(row=7, column=0)

        check2 = Checkbutton(self, text="boost games", variable=check_box["boost"])
        check2.grid(row=7, column=1)


        ### old version, may be used again later
        area = Treeview(self)
        area['show'] = 'headings'
        area["columns"] = ("one", "two", "three", "four")
        area.column("one", width=10)
        area.column("two", width=10)
        area.column("three", width=10)
        area.column("four", width=10)
        area.heading("one", text="process name")
        area.heading("two", text="Priority")
        area.heading("three", text="PID")
        area.heading("four", text="Usage")
        ###about this part
        #area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N)
        #######

        #comboboxes and relevant buttons

        self.block_drop = Combobox(self, postcommand= self.update_blocked)
        self.block_drop['values'] = working_bans
        self.block_drop.current(0)
        self.block_drop.grid(row=1, column=1, pady=1)
        self.entry = Entry(self)
        self.entry.insert(0, "enter to block")
        self.entry.grid(row=1, column=4)

        block_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(working_bans, self.block_drop.get()))
        block_btn_remv.grid(row=1, column=2)

        block_btn_add = Button(self, text="Add", command=lambda: add_to_list(working_bans, self.entry.get(), self.entry, defults["block"]))
        block_btn_add.grid(row=1, column=3)

        ############
        #boosted combo
        self.boost_drop = Combobox(self, postcommand=self.update_boosted)
        self.boost_drop['values'] = boosted
        self.boost_drop.current(0)
        self.boost_drop.grid(row=2, column=1, pady=1)
        self.entry2 = Entry(self)
        self.entry2.insert(0, "enter to buff priority")
        self.entry2.grid(row=2, column=4, pady=4)

        boost_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(boosted, self.boost_drop.get()))
        boost_btn_remv.grid(row=2, column=2)

        boost_btn_add = Button(self, text="Add", command=lambda: add_to_list(boosted, self.entry2.get(), self.entry2, defults["boost"]))
        boost_btn_add.grid(row=2, column=3)

        #########################################

        #degraded combo
        self.deg_drop = Combobox(self, postcommand=self.update_degraded)
        self.deg_drop['values'] = degraded
        self.deg_drop.current(0)
        self.deg_drop.grid(row=3, column=1, pady=1)
        self.entry3 = Entry(self)
        self.entry3.insert(0, "enter to lower priority")
        self.entry3.grid(row=3, column=4, pady=4)

        deg_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(degraded, self.deg_drop.get()))
        deg_btn_remv.grid(row=3, column=2)

        deg_btn_add = Button(self, text="Add", command=lambda: add_to_list(degraded, self.entry3.get(), self.entry3, defults["degrade"]))
        deg_btn_add.grid(row=3, column=3)

        ####
        #music combo

        self.music_drop = Combobox(self, postcommand=self.update_music)
        self.music_drop['values'] = music_list.keys()
        self.music_drop.current(0)
        self.music_drop.grid(row=4, column=1, pady=1)
        self.entry4 = Entry(self)
        self.entry4.insert(0, "enter url")
        self.entry4.grid(row=4, column=5)
        self.entry5 = Entry(self)
        self.entry5.insert(0, "enter song's name")
        self.entry5.grid(row=4, column=4)

        music_btn_remv = Button(self, text="Remove", command=lambda: remove_from_list(music_list, self.music_drop.get()))
        music_btn_remv.grid(row=4, column=2)

        music_btn_add = Button(self, text="Add", command=lambda: add_music(music_list, self.entry5.get(),self.entry4.get() ,self.entry5, defults["music"]))
        music_btn_add.grid(row=4, column=3)


        abtn = Button(self, text="Activate", command=scan_computer_programs)
        abtn.grid(row=1, column=5, sticky=E)

        sbtn = Button(self, text="Stop", command=lambda: stop_running())
        sbtn.grid(row=2, column=5, pady=6, sticky=E)

        cbtn = Button(self, text="Close", command=quit)
        cbtn.grid(row=3, column=5, pady=4, sticky=E)

        hbtn = Button(self, text="Save", command=save_lists)
        hbtn.grid(row=6, column=0, sticky=W)

        tsbtn = Button(self, text="TaskManager", command=lambda: os.system("TaskManager\pyProcMon.py"))
        tsbtn.grid(row=3, column=5, sticky=E)

        obtn = Button(self, text="start", command=lambda: call_running(area, threads["procs"], check_box))
        obtn.grid(row=6, column=5, sticky=E)

    def initUI_err(self):
        self.parent.title("Personal Helper")
        self.pack(fill=BOTH, expand=True)

    def update_boosted(self):
        self.boost_drop['values'] = boosted
        try:
            self.boost_drop.current(0)
        except:
            self.boost_drop.set("empty")

    def update_blocked(self):
        self.block_drop['values'] = working_bans
        try:
            self.block_drop.current(0)
        except:
            self.block_drop.set("empty")

    def update_degraded(self):
        self.deg_drop['values'] = degraded
        try:
            self.block_drop.current(0)
        except:
            self.block_drop.set("empty")

    def update_music(self):
        self.music_drop['values'] = music_list.keys()
        try:
            self.block_drop.current(0)
        except:
            self.block_drop.set("empty")
Ejemplo n.º 37
0
class Login(object):
    def __init__(self):
        self.root = Tk()
        self.root.title(u'用户登录')
        self.root.resizable(False, False)
        self.root.geometry('+500+500')
        self.lb_user = Label(self.root, text=u'用户名:', padx=5)
        self.lb_passwd = Label(self.root, text=u'密码:', padx=5)

        self.lb_stime = Label(self.root, text=u'日期: ', padx=5)
        self.lb_sexmp = Label(self.root, text=u'      (输入格式01,02,03)', padx=5)
        self.lb_mytext = Label(self.root, text=u'原因: ', padx=5)
        self.lb_user.grid(row=0, column=0, sticky=W)
        self.lb_passwd.grid(row=1, column=0, sticky=W)
        self.lb_stime.grid(row=2, column=0, sticky=W)
        self.lb_sexmp.grid(row=3, column=0, sticky=W)
        self.lb_mytext.grid(row=4, column=0, sticky=W)

        self.en_user = Entry(self.root, width=20)
        self.en_passwd = Entry(self.root, width=20)
        self.en_stime = Entry(self.root, width=20)
        self.en_reson = Entry(self.root, width=20)
        self.en_user.grid(row=0, column=1, columnspan=1)
        self.en_passwd.grid(row=1, column=1, columnspan=1)
        self.en_stime.grid(row=2, column=1, columnspan=1)
        self.en_reson.grid(row=4, column=1, columnspan=1, rowspan=3)

        self.var = IntVar()
        self.ckb = Checkbutton(self.root,
                               text=u'记住用户名和密码',
                               underline=0,
                               variable=self.var)
        self.ckb.grid(row=9, column=0)
        self.bt_print = Button(self.root, text=u'确定', width=20)
        self.bt_print.grid(row=9, column=1, sticky=E, pady=5)
        self.bt_print.config(command=self.print_info)
        self.checkconf()
        self.root.mainloop()

        def validate_func(self, en):
            return False if eval(en).get().strip() != '' else True

    def print_info(self):
        en1_value = self.en_user.get().strip()
        en2_value = self.en_passwd.get().strip()
        en3_value = self.en_stime.get().strip()
        nowtime = time.strftime('%Y-%m-', time.localtime(time.time()))
        real_en3_value = nowtime + en3_value + " 18:00"
        real_en4_value = nowtime + en3_value + " 20:00"
        en4_value = self.en_stime.get().strip()
        en5_value = self.en_reson.get().strip()
        #print(real_en3_value,real_en4_value)
        isok = job.test_search_in_python_org(en1_value, en2_value,
                                             real_en3_value, real_en4_value,
                                             en5_value)
        #print(isok)

    def checkconf(self):
        if os.path.exists("local.conf") and os.path.getsize("local.conf") != 0:
            list = []
            with open('local.conf', 'r') as f:
                for line in f.readlines():
                    list.append(line.strip())
                    print(line.strip())
            self.en_user.insert(0, list[0])
            self.en_passwd.insert(0, list[1])
            self.en_stime.insert(0, u'01')
            self.en_reson.insert(0, list[2])
        else:
            self.en_user.insert(0, u'input you name')
            self.en_passwd.insert(0, u'input you password')
            self.en_stime.insert(0, u'01')
            self.en_reson.insert(0, u'值班')
Ejemplo n.º 38
0
    def __init__(self, parent):
        Frame.__init__(self, parent)  
        self.parent = parent
        self.press = None
        self.grid(sticky=tk.N+tk.E+tk.S+tk.W)
        self.load_frame()
        self.load_mip()
        self.plot_mip()

        # Create rotate checkbutton
        global var1
        var1 = tk.BooleanVar()    
        rotateButton = Checkbutton(self, text = "Rotate", variable = var1, command=self.checkbutton_value1)
        rotateButton.grid(row=1, column=0, sticky=tk.E)

        # Create click checkbutton
        global var2
        var2 = tk.BooleanVar()    
        clickButton = Checkbutton(self, text = "Click", variable = var2, command=self.checkbutton_value2)
        clickButton.grid(row=1, column=1)

        # Create quit button
        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.grid(row=0, column=0, sticky=tk.N+tk.W)

        # Create interpolate button
        interpolButton = Button(self, text="Interpolate!", command=self.interpolate)
        interpolButton.grid(row=3, column=0, sticky=tk.S+tk.W)

        # resetButton = Button(self, text="Reset", command=self.resett)
        # resetButton.grid(row=4,column=0)

        # Add CNT logo
        logo_path = '%s/logo.png'%(DATA_DIR)
        logo = Image.open(logo_path)
        logo = ImageTk.PhotoImage(logo)
        label1 = Label(self, image=logo)
        label1.grid(row=0, rowspan=4, column=4)
        label1.image = logo

        # Create labels and display boxes for selected points
        label_a = Label(self, text= "A:")
        label_a.grid(row=0, column=1, sticky=tk.E+tk.S)
        global coord_a
        coord_a = Entry(self)
        coord_a.grid(row=0, column=2, sticky=tk.W+tk.S)
        label_b = Label(self, text= "B:")
        label_b.grid(row=1, column=1, sticky=tk.E+tk.N)
        global coord_b
        coord_b = Entry(self)
        coord_b.grid(row=1, column=2, sticky=tk.W+tk.N)
        label_c = Label(self, text= "C:")
        label_c.grid(row=2, column=1, sticky=tk.E+tk.N)
        global coord_c
        coord_c = Entry(self)
        coord_c.grid(row=2, column=2, sticky=tk.W+tk.N)
        label_d = Label(self, text= "D:")
        label_d.grid(row=3, column=1, sticky=tk.E+tk.N)
        global coord_d
        coord_d = Entry(self)
        coord_d.grid(row=3, column=2, sticky=tk.W+tk.N)

        # Initialized count variable that will be used to regulate number of corners
        global count
        count = 0
Ejemplo n.º 39
0
class PAGUI(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Parameter Analyzer Control")
        self.style = Style()
        self.style.theme_use("clam")
        self.pack(fill=BOTH, expand=True)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        # self.rowconfigure(3, weight=1)
        # self.rowconfigure(5, pad=7)

        #set up instance variables
        self.directory = StringVar()
        self.fname = StringVar()
        self.fname_final=StringVar()
        self.device = StringVar()
        self.chip = StringVar()
        self.run = StringVar()


        self.toplabel = Label(self, text="Dummy label at the top of the widget",justify="center")
        self.bottomlabel = Label(self, text="for help/info see github.com/leobrowning92/pa-control",justify="center",font="arial 11 italic")


        self.directory_btn = Button(self, text="Directory", command=self.askdirectory)

        self.filename_btn = Button(self, text="Filename", command=self.askfile)

        # self.exit_btn = Button(self, text="Exit", command=self.quit)
        # self.exit_btn.grid(row=5, column=0, padx=5)

        self.update_btn = Button(self, text="Update", command=self.runUpdate)

        self.iterdevice_btn = Button(self, text="Iterate [device]", command=self.newDevice)

        self.iterchip_btn = Button(self, text="Iterate [chip]", command=self.newChip)
        self.iterrun_btn = Button(self, text="Iterate [run]", command=self.newRun)

        self.chip.set("001")
        self.chipnum_entry = Entry(self, textvariable=self.chip,width=5)

        self.device.set("01")
        self.devicenum_entry = Entry(self, textvariable=self.device,width=5)

        self.run.set("001")
        self.runnum_entry = Entry(self, textvariable=self.run,width=5)

        self.directory_entry = Entry(self, textvariable=self.directory)

        self.fname.set('Chip[chip]_[device]_run[run]_somenotes_[INFO]_[time].csv')
        self.fname_final.set(make_fname_final(self.fname.get(),
                            self.chip.get(),self.device.get(),self.run.get()))

        self.fname_entry = Entry(self, textvariable=self.fname)

        self.fname_final_label = Label(self, textvariable=self.fname_final,
                          justify="center", font="arial 11 italic")


        # this button runs pulldata with parameter set by
        # self.datatype, which stores the value of self.radbtn
        self.pulldata_btn = Button(self, text="Pull Data", command=self.pulldata)

        self.datarun_btn = Button(self, text="Run Data sweep", command=self.datarun)


        #datatype=1 => diode, datatype=2 => FET
        self.datatype = IntVar()
        self.datatype1_radiobutton = Radiobutton(
            self, text='Diode (VF, IF)',
            variable=self.datatype, value=1)
        self.datatype2_radiobutton = Radiobutton(
            self, text='FET (VG, VDS, ID, IG)',
            variable=self.datatype, value=2)

        #grid alignments of all widgets
        self.toplabel.grid(column=0,columnspan=3, sticky=W, pady=4, padx=5)

        self.directory_btn.grid(row=1, column=0)
        self.directory_entry.grid(row=1, column=1, columnspan=2,
                         padx=5, sticky=E + W)

        self.filename_btn.grid(row=2, column=0)
        self.fname_entry.grid(row=2, column=1, columnspan=2,
                         padx=5, sticky=E + W)
        self.fname_final_label.grid(row=3,column=1,  columnspan=2,
                       sticky=N + E + W, pady=4, padx=5)

        self.iterchip_btn.grid(row=4, column=0, sticky=N)
        self.chipnum_entry.grid(row=4, column=1,padx=5, sticky=W)

        self.iterdevice_btn.grid(row=5, column=0, sticky=N)
        self.devicenum_entry.grid(row=5, column=1,padx=5, sticky=W)

        self.iterrun_btn.grid(row=6, column=0, sticky=N)
        self.runnum_entry.grid(row=6, column=1,padx=5, sticky=W)

        self.update_btn.grid(row=7, column=0, padx=5)
        self.pulldata_btn.grid(row=7, column=3, padx=5,sticky=E)
        self.datarun_btn.grid(row=6, column=3, padx=5,sticky=E)

        self.datatype1_radiobutton.grid(row=7,column=1,padx=5,sticky=N + E + S)
        self.datatype2_radiobutton.grid(row=7,column=2,padx=5,sticky=N + W + S)
        self.bottomlabel.grid(row=8,column=0,columnspan=3, sticky=W, pady=4, padx=5)


#action funcctions for the various buttons
    def newChip(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.chip.set(str((int(self.chip.get())+1)).zfill(3))
                self.device.set(str(1).zfill(2))
            except Exception as e:
                print(e)
            self.runUpdate()
    def newRun(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.run.set(str((int(self.run.get())+1)).zfill(3))
            except Exception as e:
                print(e)
            self.runUpdate()



    def newDevice(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.device.set(str((int(self.device.get())+1)).zfill(2))
            except Exception as e:
                print(e)
            self.runUpdate()

    def runUpdate(self):
        self.fname_final.set(make_fname_final(self.fname.get(),
                            self.chip.get(),self.device.get(),self.run.get()))


    def askdirectory(self):
        """Returns a selected directoryname."""
        self.directory.set( tkFileDialog.askdirectory())

    def askfile(self):
        fullpath = tkFileDialog.askopenfilename()
        if "/" in fullpath:
            i = fullpath.rfind("/")
        if "\\" in fullpath:
            i = fullpath.rfind("\\")
        # self.fname_final.set(fullpath[i + 1:])
        self.fname.set(fullpath[i + 1:])

    def pulldata(self):
        self.runUpdate()
        if self.datatype.get() == 1:
            download_data(['VF', 'IF'], self.fname_final.get(), self.directory.get())
        elif self.datatype.get() == 2:
            download_data(['VG', 'VDS', 'ID', 'IG'], self.fname_final.get(), self.directory.get())
    def datarun(self):
        self.runUpdate()
        if self.datatype.get() ==1:
            print("oh no we havent written a script for that yet!")
        elif self.datatype.get() == 2:
            run_FET_series(self.fname_final.get(),self.directory.get())
Ejemplo n.º 40
0
    def initUI(self):

        self.parent.title("Calculator")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)

        def calculate():
            expression = entry.get()
            entry.delete(0, END)
            entry.insert(0, str(eval(expression)))

        def evaluate(event):
            expression = entry.get()
            entry.delete(0, END)
            entry.insert(0, str(eval(expression)))

        def selectNumber(char):
            entry.insert(END, char)

        def backSpace():
            entry.delete(len(entry.get()) - 1, END)

        def deleteAll():
            entry.delete(0, END)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)
        entry.bind("<Return>", evaluate)
        cls = Button(self, text="Cls", command=lambda: deleteAll())
        cls.grid(row=1, column=0)
        bck = Button(self, text="Back", command=lambda: backSpace())
        bck.grid(row=1, column=1)
        lbl = Button(self)
        lbl.grid(row=1, column=2)
        clo = Button(self, text="Close", command=self.destroy)
        clo.grid(row=1, column=3)
        sev = Button(self, text="7", command=lambda: selectNumber("7"))
        sev.grid(row=2, column=0)
        eig = Button(self, text="8", command=lambda: selectNumber("8"))
        eig.grid(row=2, column=1)
        nin = Button(self, text="9", command=lambda: selectNumber("9"))
        nin.grid(row=2, column=2)
        div = Button(self, text="/", command=lambda: selectNumber("/"))
        div.grid(row=2, column=3)

        fou = Button(self, text="4", command=lambda: selectNumber("4"))
        fou.grid(row=3, column=0)
        fiv = Button(self, text="5", command=lambda: selectNumber("5"))
        fiv.grid(row=3, column=1)
        six = Button(self, text="6", command=lambda: selectNumber("6"))
        six.grid(row=3, column=2)
        mul = Button(self, text="*", command=lambda: selectNumber("*"))
        mul.grid(row=3, column=3)

        one = Button(self, text="1", command=lambda: selectNumber("1"))
        one.grid(row=4, column=0)
        two = Button(self, text="2", command=lambda: selectNumber("2"))
        two.grid(row=4, column=1)
        thr = Button(self, text="3", command=lambda: selectNumber("3"))
        thr.grid(row=4, column=2)
        mns = Button(self, text="-", command=lambda: selectNumber("-"))
        mns.grid(row=4, column=3)

        zer = Button(self, text="0", command=lambda: selectNumber("0"))
        zer.grid(row=5, column=0)
        dot = Button(self, text=".", command=lambda: selectNumber("."))
        dot.grid(row=5, column=1)
        equ = Button(self, text="=", command=lambda: calculate())
        equ.grid(row=5, column=2)
        pls = Button(self, text="+", command=lambda: selectNumber("+"))
        pls.grid(row=5, column=3)

        self.pack()
Ejemplo n.º 41
0
    def __init__(self, parent, txt=dict(), switcher=None):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)


        # subframes
        self.FrOptProxy = Frame(self, name='settings_proxy')
        self.FrOptIsogeo = Frame(self, name='settings_isogeo')

        # options values
        self.opt_proxy = IntVar(self)  # proxy option
        self.opt_isogeo = IntVar(self)  # Isogeo option

        # Options form widgets
        caz_prox = Checkbutton(self,
                               text=u'Proxy',
                               variable=self.opt_proxy,
                               command=lambda: switcher(self.opt_proxy,
                                                        self.FrOptProxy))
        caz_isogeo = Checkbutton(self,
                                 text=u'Isogeo',
                                 variable=self.opt_isogeo,
                                 command=lambda: switcher(self.opt_isogeo,
                                                          self.FrOptIsogeo))

        # positionning
        caz_prox.grid(row=0, column=0,
                      sticky="NSWE", padx=2, pady=2)
        self.FrOptProxy.grid(row=0, column=1, columnspan=8,
                             sticky="NSWE", padx=2, pady=2,
                             rowspan=3)
        caz_isogeo.grid(row=3, column=0,
                        sticky="NSWE", padx=2, pady=2)
        self.FrOptIsogeo.grid(row=3, column=1, columnspan=8,
                              sticky="NSWE", padx=2, pady=2,
                              rowspan=4)

        # ------------------------------------------------------------------------
        # proxy specific variables
        self.opt_ntlm = IntVar(self.FrOptProxy, 0)  # proxy NTLM protocol option
        self.prox_server = StringVar(self.FrOptProxy, 'proxy.server.com')
        self.prox_port = IntVar(self.FrOptProxy, 80)
        self.prox_user = StringVar(self.FrOptProxy, 'proxy_user')
        self.prox_pswd = StringVar(self.FrOptProxy, '****')

        # widgets
        self.prox_ent_H = Entry(self.FrOptProxy, textvariable=self.prox_server)
        self.prox_ent_P = Entry(self.FrOptProxy, textvariable=self.prox_port)
        self.prox_ent_M = Entry(self.FrOptProxy, textvariable=self.prox_pswd, show='*')

        self.prox_lb_H = Label(self.FrOptProxy, text=txt.get('gui_prox_server', "Host"))
        self.prox_lb_P = Label(self.FrOptProxy, text=txt.get('gui_port', "Port"))
        caz_ntlm = Checkbutton(self.FrOptProxy,
                               text=u'NTLM',
                               variable=self.opt_ntlm)
        self.prox_lb_M = Label(self.FrOptProxy, text=txt.get('gui_mdp', "Password"))

        # proxy widgets position
        self.prox_lb_H.grid(row=1, column=0,
                            sticky="NSEW", padx=2, pady=2)
        self.prox_ent_H.grid(row=1, column=1, columnspan=2,
                             sticky="NSEW", padx=2, pady=2)
        self.prox_lb_P.grid(row=1, column=2,
                            sticky="NSEW", padx=2, pady=2)
        self.prox_ent_P.grid(row=1, column=3, columnspan=2,
                             sticky="NSEW", padx=2, pady=2)
        caz_ntlm.grid(row=2, column=0,
                      sticky="NSEW", padx=2, pady=2)
        self.prox_lb_M.grid(row=2, column=1,
                            sticky="NSEW", padx=2, pady=2)
        self.prox_ent_M.grid(row=2, column=2, columnspan=2,
                             sticky="NSEW", padx=2, pady=2)

        # ------------------------------------------------------------------------
        # Isogeo application variables
        self.isog_app_id = StringVar(self.FrOptIsogeo, 'application_id')
        self.isog_app_tk = StringVar(self.FrOptIsogeo, 'secret')

        # widgets
        isog_ent_id = Entry(self.FrOptIsogeo,
                            textvariable=self.isog_app_id)
        isog_ent_tk = Entry(self.FrOptIsogeo,
                            textvariable=self.isog_app_tk)

        isog_lb_id = Label(self.FrOptIsogeo, text="Application ID")
        isog_lb_tk = Label(self.FrOptIsogeo, text="Application secret")

        # Isogeo widgets position
        isog_lb_id.grid(row=1, column=1,
                        sticky="NSEW", padx=2, pady=2)
        isog_ent_id.grid(row=1, column=2, columnspan=2,
                         sticky="NSEW", padx=2, pady=2)
        isog_lb_tk.grid(row=2, column=1,
                        sticky="NSEW", padx=2, pady=2)
        isog_ent_tk.grid(row=2, column=2, columnspan=2,
                         sticky="NSEW", padx=2, pady=2)
Ejemplo n.º 42
0
class Window(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()
        
    def initUI(self):
        self.parent.title("Network/Port Scan")
        self.style = Style()
        self.style.configure("TFrame", background = "#000000")
        self.style.configure("TCheckbutton", background = "#000000")
        self.style.configure("TButton", background = "#000000") 
        self.pack(fill=BOTH, expand=1)
        
        # Configure layout
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.rowconfigure(5, weight = 1)
        self.rowconfigure(6, weight = 1)
        
        # Title of program
        lbl = Label(self, text="Network/Port Scan")
        lbl.grid(sticky = W, pady=5, padx=5)

        # Text Box
        area = ScrolledText(self, height = 20)
        area.grid(row=1, column=0, columnspan=3, rowspan=4, padx=3, sticky = N+S+E+W)
        self.area = area

        # IP Address Button
        self.ip = BooleanVar()
        ip_add_button = Checkbutton(self, text="IP Address",variable=self.ip, width=10)
        ip_add_button.grid(row = 1, column = 3, sticky = N)
        ip_add_button.config(anchor = W, activebackground = "red")

        # Port Button
        self.port = BooleanVar()
        port_button = Checkbutton(self, text="Ports", variable=self.port, width=10)
        port_button.grid(row = 1, column = 3)
        port_button.config(anchor = W, activebackground = "orange")
        
        # Host Name Button
        self.host = BooleanVar()
        host_name_button = Checkbutton(self, text="Host Name",variable=self.host, width=10)
        host_name_button.grid(row = 1, column = 3, sticky = S)
        host_name_button.config(anchor = W, activebackground = "yellow")
        
        # Gateway Button
        self.gateway = BooleanVar()
        gateway_btn = Checkbutton(self, text="Gateway", variable=self.gateway, width=10)
        gateway_btn.grid(row = 2, column = 3, sticky = N)
        gateway_btn.config(anchor = W, activebackground = "green")

        # Services Button
        self.service = BooleanVar()
        service_btn = Checkbutton(self, text="Services", variable = self.service, width=10)
        service_btn.grid(row = 2, column = 3)
        service_btn.config(anchor = W, activebackground = "blue")

        # Starting IP label
        ip_label = Label(self, text = "Starting IP:  ")
        ip_label.grid(row = 5, column = 0, pady = 1, padx = 3, sticky = W)
        self.ip_from = Entry(self, width = 15)
        self.ip_from.insert(0, start_ip)
        self.ip_from.grid(row = 5 , column = 0, pady = 1, padx = 3, sticky = E)

        # Ending IP label
        ip_label_two = Label(self, text = "Ending IP:  ")
        ip_label_two.grid(row = 5, column = 1, pady = 1, padx = 5, sticky = W)
        self.ip_to = Entry(self, width = 15)
        self.ip_to.insert(0, end_ip)
        self.ip_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = E)
        
        # Starting Port Label
        port_label = Label(self, text = "Starting Port:  ")
        port_label.grid(row = 5, column = 0, pady = 3, padx = 5, sticky = S+W)
        self.port_from = Entry(self, width = 15)
        self.port_from.insert(0, 0)
        self.port_from.grid(row = 5 , column = 0, pady = 1, padx = 5, sticky = S+E)

        # Ending Port Label
        port_label_two = Label(self, text = "Ending Port:  ")
        port_label_two.grid(row = 5, column = 1, pady = 3, padx = 5, sticky = S+W)
        self.port_to = Entry(self, width = 15)
        self.port_to.insert(0, 1025)
        self.port_to.grid(row = 5 , column = 1, pady = 1, padx = 5, sticky = S+E)

        # Scan Me 
        self_scan_button = Button(self, text="Scan Me", command = lambda : self.onClick(1), width = 33)
        self_scan_button.grid(row = 6, column = 1, sticky = N)

        # Scan near me Button
        scan_other_button = Button(self, text="Scan Near Me", width = 33, command = lambda : self.onClick(2))
        scan_other_button.grid(row = 6, column = 0, pady=1, sticky = N)
        
        # Clear button
        clear_button = Button(self, text="Clear text", command = self.clear_text, width = 12)
        clear_button.grid(row = 6, column = 3, pady=1, sticky = N)

        # Progress Bar
        self.label_scanning = Progressbar(self, orient = HORIZONTAL, length = 175)
        self.label_scanning.grid(row = 6, column = 0, columnspan = 4, padx = 7, pady = 7, sticky = E+S+W)
        self.label_scanning.config(mode = "determinate")

     
    # Clear what is in the text box.   
    def clear_text(self):
        self.area.delete(0.0, 'end')
        # empty my lists.
        my_ports[:] = []
        ip_address_up[:] = []
        target_host_name[:] = []
        target_port_up[:] = []
        
    # On click methods for scan me and scan others.
    def onClick(self, button_id):
        
        if button_id == 1:
            
            # Check to see if host button is marked
            if self.host.get() == 1:
                message = my_host_name()
                self.area.insert(0.0, message, ("warning"))
                self.area.tag_configure("warning", foreground = "blue")    
                
            # Check to see if ports button is marked   
            if self.port.get() == 1:
                # Check port entry widgets. 
                if self.port_from:
                    if self.port_to:
                        # Get the user input
                        starting_port = self.port_from.get()
                        ending_port = self.port_to.get()                
                        message, total = scan_my_ports(int(starting_port), int(ending_port))
                        for i in message:
                            new_message = "My TCP " + i + "\n"
                            self.area.insert(0.0, new_message, ("ports"))
                            #self.area.tag_configure("ports", foreground = "green")
                    
                    time = "The TCP port scan completed in: " + str(total) + "\n"
                    self.area.insert(0.0, time, ("timing"))
                    self.area.tag_configure("timing", foreground = "red")
                else:
                    self.area.insert(0.0, "No valid ports specified.")
                
            # Check to see if IP button is marked     
            if self.ip.get() == 1:
                message = my_ip()
                self.area.insert(0.0, message)
            
            # Check if gateway button is marked.
            if self.gateway.get() == 1:
                message = my_gateway()
                self.area.insert(0.0, message)

            # Check if service button is marked.
            if self.service.get() == 1:
                message, time = scan_my_services()
                for i in message:
                    new_message = i + "\n"
                    self.area.insert(0.0, new_message)
                new_time = "The local scan completed in: " + str(time) + "\n"
                self.area.insert(0.0. new_time, ("timing"))
                self.area.tag_configure("timing", foreground = "red")
                
        # If Scan other button is clicked. 
        elif button_id == 2:
            
            # Check other IP's 
            if self.ip.get() == 1:
                # Check the entry widgets.
                if self.ip_from:
                    if self.ip_to:
                        # Get the ranges from the entry widgets
                        starting_ipv4_address = self.ip_from.get()
                        ending_ipv4_address = self.ip_to.get()
                        
                        # Pass the values from the entry widgets into the function to scan nearby IP addresses.
                        message, time = ping_ip_other(starting_ipv4_address, ending_ipv4_address)
                        if message:
                            for i in message:
                                new_message = "The address:     {:>15} {:>15}".format(i,"is UP\n")
                                self.area.insert(0.0, new_message)
                        
                        total_time =  "Range scanned: " + str(starting_ipv4_address) +" to " + str(ending_ipv4_address) + "\n" + "The IP scan completed in:  " + str(time) + "\n"
                        self.area.insert(0.0, total_time, ("timing"))
                        self.area.tag_configure("timing", foreground = "red")

                else:
                    self.area.insert(0.0, "No Ip range is specified.")
                
                
            # Check others Ports
            if self.port.get() == 1:
                # Check port entry widgets. 
                if self.port_from:
                    if self.port_to:
                        # Get the user input
                        starting_port = self.port_from.get()
                        ending_port = self.port_to.get()
                        
                        
                        message, time = scan_ports_other(int(starting_port), int(ending_port))
                        if message:
                            for i in message:
                                new_msg = "The " + i +"\n"
                                self.area.insert(0.0, new_msg)
                        else:
                            new_msg = "Must scan nearby IP addresses first.\n"
                    
                    total_time = "TCP Port scan completed in: " + str(time) + "\n"
                    self.area.insert(0.0, total_time, ("timing"))
                    self.area.tag_configure("timing", foreground = "red")
                    
                else:
                    self.area.insert(0.0, "No Port range specified.")
            
            # Check other host names. Based on IP's scanned.
            if self.host.get() == 1:
                message, time = scan_host_other(ip_address_up)
                # Check that IP's of other computers were collected 
                if message:
                    for i in message:
                        new_message = "Host name: "+ str(i) + "\n"
                        self.area.insert(0.0, new_message)

                else:
                    new_msg = "Must scan nearby IP addresses first. \n"
                    self.area.insert(0.0, new_msg)
                    
                total = "The host scan completed in: " + str(time) + "\n"
                self.area.insert(0.0, total, ("timing"))
                self.area.tag_configure("timing", foreground = "red")
                
            # Check gateway return the gateway of the host machine again.
            if self.gateway.get() == 1:
                message = "\n" + str(my_gateway())
                self.area.insert(0.0, message)

            # Check what services are running on which IP and port.
            if self.service.get() == 1:
                message, time = services_other()
                if message:
                    for i in message:
                        new_message = i + "\n"
                        self.area.insert(0.0, new_message)
                    
                else:
                    new_msg = "The IP addresses and ports must be scanned first."
                    self.area.insert(0.0, new_msg)
                    
                new_time = "The service scan completed in: " + str(time) + "\n"
                self.area.insert(0.0, new_time, ("timing"))
                self.area.tag_configure("timing", foreground = "red")
                
        else:
            pass
Ejemplo n.º 43
0
class SelectPaths(MyFrame):
    def __init__(self, topframe=None):

        MyFrame.__init__(self, topframe=topframe)

        style = Style()
        style.theme_use('clam')

        self.patient_foler_path = ""
        self.patients = []
        self.set_title('Brain segmentation GUI')
        self.add_ui_components()

    def add_ui_components(self):

        # Creating the frames.
        self.sub_frame1 = Frame(self)
        self.sub_frame1.grid(column=0, row=0)

        sub_frame2 = Frame(self)
        sub_frame2.grid(column=0, row=1)

        sub_frame3 = Frame(self)
        sub_frame3.grid(column=0, row=2)

        sub_frame21 = Frame(sub_frame2)
        sub_frame21.grid(column=0, row=0)

        sub_frame22 = Frame(sub_frame2)
        sub_frame22.grid(padx=20, column=1, row=0)

        sub_frame221 = Frame(sub_frame22)
        sub_frame221.grid(row=1, column=0)

        # Creating the top-menu buttons.
        self.visualise_button = Button(self.sub_frame1,
                                       text="Visualise",
                                       command=self.start_visualisation)
        self.visualise_button.grid(row=0, column=1)

        self.help_button = Button(self.sub_frame1,
                                  text="Help",
                                  command=self.open_help)
        self.help_button.grid(row=0, column=2)

        # Creating the select modality path.
        self.modality_label = Label(sub_frame21,
                                    text="Path to patient folders",
                                    relief=FLAT)
        self.modality_label.grid(row=1, column=1)
        self.modality_path_entry = Entry(sub_frame21)
        self.modality_path_entry.grid(row=2, column=1)
        #self.modality_path_entry.set(self.patient_folder_path)

        self.modality_path_button = Button(
            sub_frame21,
            text="Choose",
            command=self.choose_directory_and_import)
        self.modality_path_button.grid(row=2, column=2)

        # Creating the patients listbox.
        self.label_patients = Label(sub_frame22, text="Patients")
        self.label_patients.grid(row=0, column=0)

        self.listbox_patients = Listbox(sub_frame221,
                                        selectmode='multiple',
                                        width=50,
                                        height=10)

        self.listbox_patients.pack(side=LEFT, fill=Y)
        #self.listbox_patients.grid(row=1, column=0)
        self.listbox_patients.bind("<Button-1>", self.listbox_changed)

        self.scrollbar = Scrollbar(sub_frame221)
        self.scrollbar.pack(side=RIGHT, fill=Y)

        # attach listbox to scrollbar
        self.listbox_patients.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.listbox_patients.yview)
        # Creating the status console.
        self.status_text = Text(sub_frame3, height=5)
        self.status_text.grid(column=0, row=0)
        self.status_text.tag_configure('title',
                                       justify='center',
                                       font="Arial 10 bold")
        self.status_text.tag_configure('entry', justify='left', font="Arial 9")
        self.status_text.insert(END, 'Status Console', 'title')
        self.status_text_entry_number = 1
        self.status_text.configure(state='disabled')

# ***** EVENTS - START********************************

    def start_visualisation(self):
        """ Launch visualisation module. 
        Linked to self.visualise_button (Button). """

        patient_path = os.path.join(self.patient_folder_path,
                                    'processed_' + self.patients[0])

        segmentation_path = os.path.join(
            patient_path, SEGM_PREFIX + '_' + self.patients[0] + '.nii.gz')

        supervoxel_path = os.path.join(
            patient_path,
            SUPERVOXEL_PREFIX + '_' + self.patients[0] + '.nii.gz')

        # check if the supervoxels and the segmentation exist
        if not os.path.exists(supervoxel_path):
            supervoxel_path = None
        if not os.path.exists(segmentation_path):
            segmentation_path = None

        mod_paths = []
        for mod in MODALITY_PREFIXES:
            mod_paths.append(\
                    os.path.join(patient_path,
                                 mod+'_'+self.patients[0]+'.nii.gz'))

        vis = vv.VisualVolumes(image_paths=mod_paths,
                               segm_path=segmentation_path,
                               supervoxel_id_path=supervoxel_path,
                               topframe=self.master)
        vis.tkraise()

    def listbox_changed(self, event):
        """ Add a patient upon selection in the listbox. 
        Linked to self.listbox_patients (Listbox). """

        indices = list(self.listbox_patients.curselection())
        selected_idx = self.listbox_patients.nearest(event.y)

        if selected_idx == -1:
            return

        # remove or add a patient index
        if selected_idx not in indices:
            indices.append(selected_idx)
        else:
            indices.remove(selected_idx)

        # set self.patients based on the new patient indices and enable visualisation if only one is selected.
        self.patients = []
        for idx in indices:
            self.patients.append(self.listbox_patients.get(idx).split(' ')[0])
        if len(self.patients) == 1:
            self.visualise_button['state'] = 'enabled'
        else:
            self.visualise_button['state'] = 'disabled'

    def choose_directory_and_import(self):
        """ Allow the user to select an import path. 
	    Linked to self.modality_path_button (Button), 
	    and sets self.modality_path_entry (Entry). """

        initialdir = DATA_PATH
        msg = 'Select directory containing patients'
        path = askdirectory(title=msg, initialdir=initialdir)
        # update the text box.
        self.modality_path_entry.delete(0, END)
        self.modality_path_entry.insert(0, str(path))

        # Adding the modality paths after the folder is selected.
        self.patient_folder_path = self.modality_path_entry.get()
        if os.path.exists(self.patient_folder_path):

            patients_validation = os.listdir(self.patient_folder_path)

            # Checking if the patient has the right modalities and importing the patient.
            for i, patient in enumerate(patients_validation):

                # Checking if the patient was already processed.
                if patient.startswith('processed_') or os.path.exists(
                        os.path.join(self.patient_folder_path,
                                     'processed_' + patient)):
                    print("The files of the patient " + patient +
                          " are already copied")
                    continue

                # If everything is fine, then it continues to makign folders and copying files
                # Copying the files into the new folder.
                valid = self._convert_and_copy_files(patient)
                if not valid:
                    patients_validation[i] = None

            # We make a list of patients with only ids for the listbox.
            valid_patients = [p for p in patients_validation if p is not None]
            self.list_existing_patients(valid_patients)

    def _convert_and_copy_files(self, patient):
        """ Check if all valid files exist for this patient and return
        True if so. """

        # Getting the list of modalities for every patient.
        patient_path = os.path.join(self.patient_folder_path, patient)
        modalities = os.listdir(patient_path)

        # Look for paths
        valid_paths = {}
        prefices = [SEGM_PREFIX, SUPERVOXEL_PREFIX] + MODALITY_PREFIXES
        for prefix in prefices:
            candidates = [modality \
                          for modality in modalities \
                          if modality.startswith(prefix+'.')]
            if len(candidates) != 1:
                err = '%s file not identified. Look for ambiguities in %s.' \
                        % (prefix, patient_path)
                print(err)
                return False
            modality = candidates[0]

            if not any([
                    modality.endswith(ext)
                    for ext in ['.mha', '.nii', '.nii.gz']
            ]):
                err = "Image format not recognized: %s. In %s" \
                            % (modality, patient_path)
                print(err)
                return False

            valid_paths[prefix] = modality

        # Creating a processed patient folder.
        os.mkdir(os.path.join(self.patient_folder_path,
                              'processed_' + patient))
        for prefix, basename in valid_paths.iteritems():
            shutil.copyfile(
                os.path.join(self.patient_folder_path, patient, basename),
                os.path.join(self.patient_folder_path, 'processed_' + patient,
                             prefix + '_' + patient + '.nii.gz'))
        return True

    def open_help(self):

        self.help_window = help_window.HelpWindow()
        self.help_window.tkraise()


# ***** EVENTS - END***************************

    def list_existing_patients(self, patients=None):
        print("Importing existing patients")
        # We make a list of patients with only ids for the listbox.

        if patients is None:
            patients = os.listdir(self.patient_folder_path)
        self.patients = []
        for patient in patients:
            if not patient.startswith('processed_'):
                self.patients.append(patient)
        self.patients.sort()
        self.populate_patient_listbox(self.patients)

        if self.listbox_patients.size() > 0:
            self.listbox_patients.selection_set(0)

        self.status_text.configure(state='normal')
        self.status_text.insert(
            END, '\n' + str(self.status_text_entry_number) +
            '- Patients are imported.', 'entry')
        self.status_text_entry_number += 1
        self.status_text.insert(
            END, '\n' + str(self.status_text_entry_number) +
            '- Please select a patient to proceed', 'entry')
        self.status_text_entry_number += 1
        self.status_text.configure(state='disabled')

    def populate_patient_listbox(self, patients):

        self.listbox_patients.delete(0, END)
        for patient in patients:
            patient_path = os.path.join(self.patient_folder_path,
                                        'processed_' + patient)

            #check if a given patient has a label
            if os.path.exists(
                    os.path.join(
                        patient_path, 'corrected_' + SEGM_PREFIX + '_' +
                        patient + '.nii.gz')):
                patient = patient + ' - segmentation corrected'
            self.listbox_patients.insert(END, patient)
Ejemplo n.º 44
0
 def initUI(self):
   
     self.parent.title("Calculator")
     
     Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')
     
     self.columnconfigure(0, pad=3)
     self.columnconfigure(1, pad=3)
     self.columnconfigure(2, pad=3)
     self.columnconfigure(3, pad=3)
     
     self.rowconfigure(0, pad=3)
     self.rowconfigure(1, pad=3)
     self.rowconfigure(2, pad=3)
     self.rowconfigure(3, pad=3)
     self.rowconfigure(4, pad=3)
     
     entry = Entry(self)
     entry.grid(row=0, columnspan=4, sticky=W+E)
     
     cls = Button(self, text="Cls")
     cls.grid(row=1, column=0)
     bck = Button(self, text="Back")
     bck.grid(row=1, column=1)
     lbl = Button(self)
     lbl.grid(row=1, column=2)    
     clo = Button(self, text="Close")
     clo.grid(row=1, column=3)        
     sev = Button(self, text="7")
     sev.grid(row=2, column=0)        
     eig = Button(self, text="8")
     eig.grid(row=2, column=1)         
     nin = Button(self, text="9")
     nin.grid(row=2, column=2) 
     div = Button(self, text="/")
     div.grid(row=2, column=3) 
     
     fou = Button(self, text="4")
     fou.grid(row=3, column=0)        
     fiv = Button(self, text="5")
     fiv.grid(row=3, column=1)         
     six = Button(self, text="6")
     six.grid(row=3, column=2) 
     mul = Button(self, text="*")
     mul.grid(row=3, column=3)    
     
     one = Button(self, text="1")
     one.grid(row=4, column=0)        
     two = Button(self, text="2")
     two.grid(row=4, column=1)         
     thr = Button(self, text="3")
     thr.grid(row=4, column=2) 
     mns = Button(self, text="-")
     mns.grid(row=4, column=3)         
     
     zer = Button(self, text="0")
     zer.grid(row=5, column=0)        
     dot = Button(self, text=".")
     dot.grid(row=5, column=1)         
     equ = Button(self, text="=")
     equ.grid(row=5, column=2) 
     pls = Button(self, text="+")
     pls.grid(row=5, column=3)
     
     self.pack()
Ejemplo n.º 45
0
frame = Frame(the_window)

Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

frame.columnconfigure(0, pad=3)
frame.columnconfigure(1, pad=3)
frame.columnconfigure(2, pad=3)
frame.columnconfigure(3, pad=3)

frame.rowconfigure(0, pad=3)
frame.rowconfigure(1, pad=3)
##  ENTRY  ###
band1Label = Label(frame, text='Band 1')
band1Label.grid(row=0, column=0)
band1Entry = Entry(frame)
band1Entry.grid(row=0, column=1)
band2Label = Label(frame, text='Band 2')
band2Label.grid(row=0, column=2)
band2Entry = Entry(frame)
band2Entry.grid(row=0, column=3)
band3Label = Label(frame, text='Band 3')
band3Label.grid(row=1, column=0)
band3Entry = Entry(frame)
band3Entry.grid(row=1, column=1)
band4Label = Label(frame, text='Band 4')
band4Label.grid(row=1, column=2)
band4Entry = Entry(frame)
band4Entry.grid(row=1, column=3)
##  BUTTONS  ###
sizeMagButton = Button(frame, text="Size Magnitude", command=sizeMag)
sizeMagButton.grid(row=2, column=0)
Ejemplo n.º 46
0
class GripperDemo(Frame):
    def __init__(self, parent1):
        Frame.__init__(self, parent1)
        self.parent = parent1
        self.initUI()

    def initUI(self):
        self.parent.title("Gripper Demo")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        #scale1 - Gripper Pos
        ScaleGripperPos = Scale(self,
                                from_=0,
                                to=100,
                                orient=HORIZONTAL,
                                length=300,
                                resolution=1,
                                command=self.onScaleGripperPos)
        ScaleGripperPos.grid(row=1, column=2)

        self.label = Label(self, text="Gripper Pos ")
        self.label.grid(row=1, column=1)

        self.GripperPos = IntVar()
        self.labelScaleGripperPos = Label(self,
                                          text=0,
                                          textvariable=self.GripperPos)
        self.labelScaleGripperPos.grid(row=1, column=3)

        #scale2 - X ROTATION
        scaleRotX = Scale(self,
                          from_=0,
                          to=650,
                          orient=HORIZONTAL,
                          length=300,
                          resolution=1,
                          command=self.onScaleXAxisRot)
        scaleRotX.grid(row=2, column=2)
        scaleRotX.set(450)

        self.label = Label(self, text="X Axis Rotation ")
        self.label.grid(row=2, column=1)

        self.labelRotX = Label(self)
        self.labelRotX.grid(row=2, column=3)

        #Entry1 - Force
        self.entryForce = Entry(self)
        self.entryForce.grid(row=3, column=2)
        self.entryForce.insert(0, "50")  #35=700

        #self.forceString = StringVar()
        #self.forceString.set(1023);
        self.labelForce = Label(self)
        self.labelForce.grid(row=3, column=3)
        #self.entryForce.insert(1023,self.force.get())
        #self.entry1.delete(0,END) #delete entry text
        #entry.bind("<Return>", callback) #calls callback function after hit "enter"

        self.label = Label(self, text="Current (A)")
        self.label.grid(row=6, column=1)
        self.labelCurrent = Label(self)
        self.labelCurrent.grid(row=6, column=3)

        #Entry2 - Speed
        self.entrySpeed = Entry(self)
        self.entrySpeed.grid(row=4, column=2)
        self.entrySpeed.insert(0, "4000")
        self.labelSpeed = Label(self)
        self.labelSpeed.grid(row=4, column=3)

        #Entry2 - Active Distance
        self.entryDistance = Entry(self)
        self.entryDistance.grid(row=5, column=2)

        #Entry3 - Send Command
        self.entrySendCommand = Entry(self)
        self.entrySendCommand.grid(row=8, column=2)

        self.activeDistance = IntVar()
        self.activeDistance.set(15)
        self.labelActiveDistance = Label(self)
        self.labelActiveDistance.grid(row=5, column=3)
        self.entryDistance.insert(0, self.activeDistance.get())

        #Button1 - close
        self.button1 = Button(self, text="close", command=self.gripperClose)
        self.button1.grid(row=7, column=1)
        #Button2 - open
        self.button2 = Button(self, text="open", command=self.gripperOpen)
        self.button2.grid(row=7, column=2)
        #Button3 - home
        self.button3 = Button(self,
                              text="home",
                              command=self.gripperHomeRoutine)
        self.button3.grid(row=7, column=3)
        #Button4 - send command
        self.button4 = Button(self, text="send", command=self.sendCommand)
        self.button4.grid(row=8, column=3)
        #Button3
        self.buttonForce = Button(self,
                                  text="forceSetPoint (mg)",
                                  command=self.gripperSetForce)
        self.buttonForce.grid(row=3, column=1)
        #Button4
        self.buttonSpeed = Button(self,
                                  text="speedSetPoint (mseg/close)",
                                  command=self.gripperSetSpeed)
        #80degree each finger = to move 40 degree to close
        self.buttonSpeed.grid(row=4, column=1)
        #Button5
        self.buttonDistance = Button(self,
                                     text="distanceSetPoint (Cm)",
                                     command=self.gripperSetDistance)
        self.buttonDistance.grid(row=5, column=1)

    def gripperOpen(self):
        message = "open"
        rospy.loginfo(message)
        pub.publish(message)

    def gripperClose(self):
        message = "close_101"  #101 is the auto close command
        rospy.loginfo(message)
        pub.publish(message)

    def gripperHomeRoutine(self):
        message = "home"
        rospy.loginfo(message)
        pub.publish(message)

    def sendCommand(self):
        message = self.entrySendCommand.get()
        rospy.loginfo(message)
        pub.publish(message)

    def gripperSetForce(self):
        aux = map(int(self.entryForce.get()), 0, 1200, 0, 1023)
        message = "setForce_" + str(aux)
        rospy.loginfo(message)
        pub.publish(message)

    def gripperSetSpeed(self):
        #0.174seg 80graus (6.0V sem carga)
        #4s 80 graus na velocidade minima 50ms
        aux = map(int(self.entrySpeed.get()), 4000, 174, 50, 0)
        if aux < 0:
            aux = 0
        message = "setSpeed_" + str(aux)
        rospy.loginfo(message)
        pub.publish(message)

    def gripperSetDistance(self):
        aux = self.entryDistance.get()
        message = "setDistance_" + str(aux)
        rospy.loginfo(message)
        pub.publish(message)

    def onScaleGripperPos(self, x):
        aux = int(float(x))
        self.GripperPos.set(aux)
        message = "close_" + str(aux)
        rospy.loginfo(message)
        pub.publish(message)

    def onScaleXAxisRot(self, x):
        aux = int(float(x))
        message = "rotate_" + str(aux)
        rospy.loginfo(message)
        pub.publish(message)

    def updateLabels(self):
        aux = map(gripperForce.data, 0, 1023, 0, 1200)
        self.labelForce.config(text=str(aux))
        aux = int(self.entrySpeed.get())
        if aux < 174:
            aux = 174
        self.labelSpeed.config(text=str(aux))
        self.labelActiveDistance.config(text=str(gripperDistance.data))
        self.labelRotX.config(text=str(gripperRotationX.data))
        self.labelCurrent.config(text=str((gripperCurrent.data - 511) * 0.024))
Ejemplo n.º 47
0
    def initUI(self):

        self.parent.title("Resistor Calculator")

        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)
        self.columnconfigure(4, pad=3)
        self.columnconfigure(5, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)
        self.rowconfigure(5, pad=3)
        self.rowconfigure(6, pad=3)
        self.rowconfigure(7, pad=3)
        self.rowconfigure(8, pad=3)
        self.rowconfigure(9, pad=3)
        self.rowconfigure(10, pad=3)
        self.rowconfigure(11, pad=3)
        self.rowconfigure(12, pad=3)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)
        global resistance
        resistance = ""

        def ringOne(number):
            entry.delete(0, END)
            entry.insert(0, str(number))
            global resistance
            resistance = resistance + str(number)

        def ringTwo(number):
            ent = str(number)
            entry.insert(END, str(number))
            global resistance
            resistance = resistance + str(number)

        def ringThree(number):
            ent = str(number)
            entry.insert(END, str(number))
            global resistance
            resistance = resistance + str(number)

        def ringFour(number):
            global resistance
            entry.delete(0, END)
            for x in range(0, number):
                resistance = resistance + "0"
            ent = "Resistance is: " + resistance
            entry.insert(END, ent)
            resistance = ""

        def cls():
            global resistance
            resistance = ""
            entry.delete(0, END)
            entry.insert(0, "Please Select ring colors")

        entry.insert(0, "Please Select ring colors")
        entry.config(justify=RIGHT)

        black = Button(self, text="Black", command=lambda: ringOne(0))
        black.grid(row=2, column=0)
        brown = Button(self, text="Brown", command=lambda: ringOne(1))
        brown.grid(row=3, column=0)
        red = Button(self, text="Red", command=lambda: ringOne(2))
        red.grid(row=4, column=0)
        orange = Button(self, text="Orange", command=lambda: ringOne(3))
        orange.grid(row=5, column=0)
        yellow = Button(self, text="Yellow", command=lambda: ringOne(4))
        yellow.grid(row=6, column=0)
        green = Button(self, text="Green", command=lambda: ringOne(5))
        green.grid(row=7, column=0)
        blue = Button(self, text="Blue", command=lambda: ringOne(6))
        blue.grid(row=8, column=0)
        violet = Button(self, text="Violet", command=lambda: ringOne(7))
        violet.grid(row=9, column=0)
        grey = Button(self, text="Grey", command=lambda: ringOne(8))
        grey.grid(row=10, column=0)
        white = Button(self, text="White", command=lambda: ringOne(9))
        white.grid(row=11, column=0)

        black2 = Button(self, text="Black", command=lambda: ringTwo(0))
        black2.grid(row=2, column=1)
        brown2 = Button(self, text="Brown", command=lambda: ringTwo(1))
        brown2.grid(row=3, column=1)
        red2 = Button(self, text="Red", command=lambda: ringTwo(2))
        red2.grid(row=4, column=1)
        orange2 = Button(self, text="Orange", command=lambda: ringTwo(3))
        orange2.grid(row=5, column=1)
        yellow2 = Button(self, text="Yellow", command=lambda: ringTwo(4))
        yellow2.grid(row=6, column=1)
        green2 = Button(self, text="Green", command=lambda: ringTwo(5))
        green2.grid(row=7, column=1)
        blue2 = Button(self, text="Blue", command=lambda: ringTwo(6))
        blue2.grid(row=8, column=1)
        violet2 = Button(self, text="Violet", command=lambda: ringTwo(7))
        violet2.grid(row=9, column=1)
        grey2 = Button(self, text="Grey", command=lambda: ringTwo(8))
        grey2.grid(row=10, column=1)
        white2 = Button(self, text="White", command=lambda: ringTwo(9))
        white2.grid(row=11, column=1)

        black3 = Button(self, text="Black", command=lambda: ringThree(0))
        black3.grid(row=2, column=2)
        brown3 = Button(self, text="Brown", command=lambda: ringThree(1))
        brown3.grid(row=3, column=2)
        red3 = Button(self, text="Red", command=lambda: ringThree(2))
        red3.grid(row=4, column=2)
        orange3 = Button(self, text="Orange", command=lambda: ringThree(3))
        orange3.grid(row=5, column=2)
        yellow3 = Button(self, text="Yellow", command=lambda: ringThree(4))
        yellow3.grid(row=6, column=2)
        green3 = Button(self, text="Green", command=lambda: ringThree(5))
        green3.grid(row=7, column=2)
        blue3 = Button(self, text="Blue", command=lambda: ringThree(6))
        blue3.grid(row=8, column=2)
        violet3 = Button(self, text="Violet", command=lambda: ringThree(7))
        violet3.grid(row=9, column=2)
        grey3 = Button(self, text="Grey", command=lambda: ringThree(8))
        grey3.grid(row=10, column=2)
        white3 = Button(self, text="White", command=lambda: ringThree(9))
        white3.grid(row=11, column=2)

        black4 = Button(self, text="Black", command=lambda: ringFour(0))
        black4.grid(row=2, column=3)
        brown4 = Button(self, text="Brown", command=lambda: ringFour(1))
        brown4.grid(row=3, column=3)
        red4 = Button(self, text="Red", command=lambda: ringFour(2))
        red4.grid(row=4, column=3)
        orange4 = Button(self, text="Orange", command=lambda: ringFour(3))
        orange4.grid(row=5, column=3)
        yellow4 = Button(self, text="Yellow", command=lambda: ringFour(4))
        yellow4.grid(row=6, column=3)
        green4 = Button(self, text="Green", command=lambda: ringFour(5))
        green4.grid(row=7, column=3)
        blue4 = Button(self, text="Blue", command=lambda: ringFour(6))
        blue4.grid(row=8, column=3)
        violet4 = Button(self, text="Violet", command=lambda: ringFour(7))
        violet4.grid(row=9, column=3)
        grey4 = Button(self, text="Grey", command=lambda: ringFour(8))
        grey4.grid(row=10, column=3)
        white4 = Button(self, text="White", command=lambda: ringFour(9))
        white4.grid(row=11, column=3)

        i = 0
        labels = "Ring 1", "Ring 2", "Ring 3", "Multiplier"
        for label in labels:
            label1 = Label(self, text=label)
            label1.grid(row=1, column=i)
            i += 1

        clear = Button(self, text="Clear", command=lambda: cls())
        clear.grid(row=12, columnspan=4, sticky=W + E)

        self.pack()
Ejemplo n.º 48
0
class Window(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Network/Port Scan")
        self.style = Style()
        self.style.configure("TFrame", background="#000000")
        self.style.configure("TCheckbutton", background="#000000")
        self.style.configure("TButton", background="#000000")
        self.pack(fill=BOTH, expand=1)

        # Configure layout
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, weight=1)
        self.rowconfigure(5, weight=1)
        self.rowconfigure(6, weight=1)

        # Title of program
        lbl = Label(self, text="Network/Port Scan")
        lbl.grid(sticky=W, pady=5, padx=5)

        # Text Box
        area = ScrolledText(self, height=20)
        area.grid(row=1,
                  column=0,
                  columnspan=3,
                  rowspan=4,
                  padx=3,
                  sticky=N + S + E + W)
        self.area = area

        # IP Address Button
        self.ip = BooleanVar()
        ip_add_button = Checkbutton(self,
                                    text="IP Address",
                                    variable=self.ip,
                                    width=10)
        ip_add_button.grid(row=1, column=3, sticky=N)
        ip_add_button.config(anchor=W, activebackground="red")

        # Port Button
        self.port = BooleanVar()
        port_button = Checkbutton(self,
                                  text="Ports",
                                  variable=self.port,
                                  width=10)
        port_button.grid(row=1, column=3)
        port_button.config(anchor=W, activebackground="orange")

        # Host Name Button
        self.host = BooleanVar()
        host_name_button = Checkbutton(self,
                                       text="Host Name",
                                       variable=self.host,
                                       width=10)
        host_name_button.grid(row=1, column=3, sticky=S)
        host_name_button.config(anchor=W, activebackground="yellow")

        # Gateway Button
        self.gateway = BooleanVar()
        gateway_btn = Checkbutton(self,
                                  text="Gateway",
                                  variable=self.gateway,
                                  width=10)
        gateway_btn.grid(row=2, column=3, sticky=N)
        gateway_btn.config(anchor=W, activebackground="green")

        # Services Button
        self.service = BooleanVar()
        service_btn = Checkbutton(self,
                                  text="Services",
                                  variable=self.service,
                                  width=10)
        service_btn.grid(row=2, column=3)
        service_btn.config(anchor=W, activebackground="blue")

        # Starting IP label
        ip_label = Label(self, text="Starting IP:  ")
        ip_label.grid(row=5, column=0, pady=1, padx=3, sticky=W)
        self.ip_from = Entry(self, width=15)
        self.ip_from.insert(0, start_ip)
        self.ip_from.grid(row=5, column=0, pady=1, padx=3, sticky=E)

        # Ending IP label
        ip_label_two = Label(self, text="Ending IP:  ")
        ip_label_two.grid(row=5, column=1, pady=1, padx=5, sticky=W)
        self.ip_to = Entry(self, width=15)
        self.ip_to.insert(0, end_ip)
        self.ip_to.grid(row=5, column=1, pady=1, padx=5, sticky=E)

        # Starting Port Label
        port_label = Label(self, text="Starting Port:  ")
        port_label.grid(row=5, column=0, pady=3, padx=5, sticky=S + W)
        self.port_from = Entry(self, width=15)
        self.port_from.insert(0, 0)
        self.port_from.grid(row=5, column=0, pady=1, padx=5, sticky=S + E)

        # Ending Port Label
        port_label_two = Label(self, text="Ending Port:  ")
        port_label_two.grid(row=5, column=1, pady=3, padx=5, sticky=S + W)
        self.port_to = Entry(self, width=15)
        self.port_to.insert(0, 1025)
        self.port_to.grid(row=5, column=1, pady=1, padx=5, sticky=S + E)

        # Scan Me
        self_scan_button = Button(self,
                                  text="Scan Me",
                                  command=lambda: self.onClick(1),
                                  width=33)
        self_scan_button.grid(row=6, column=1, sticky=N)

        # Scan near me Button
        scan_other_button = Button(self,
                                   text="Scan Near Me",
                                   width=33,
                                   command=lambda: self.onClick(2))
        scan_other_button.grid(row=6, column=0, pady=1, sticky=N)

        # Clear button
        clear_button = Button(self,
                              text="Clear text",
                              command=self.clear_text,
                              width=12)
        clear_button.grid(row=6, column=3, pady=1, sticky=N)

        # Progress Bar
        self.label_scanning = Progressbar(self, orient=HORIZONTAL, length=175)
        self.label_scanning.grid(row=6,
                                 column=0,
                                 columnspan=4,
                                 padx=7,
                                 pady=7,
                                 sticky=E + S + W)
        self.label_scanning.config(mode="determinate")

    # Clear what is in the text box.
    def clear_text(self):
        self.area.delete(0.0, 'end')
        # empty my lists.
        my_ports[:] = []
        ip_address_up[:] = []
        target_host_name[:] = []
        target_port_up[:] = []

    # On click methods for scan me and scan others.
    def onClick(self, button_id):

        if button_id == 1:

            # Check to see if host button is marked
            if self.host.get() == 1:
                message = my_host_name()
                self.area.insert(0.0, message, ("warning"))
                self.area.tag_configure("warning", foreground="blue")

            # Check to see if ports button is marked
            if self.port.get() == 1:
                # Check port entry widgets.
                if self.port_from:
                    if self.port_to:
                        # Get the user input
                        starting_port = self.port_from.get()
                        ending_port = self.port_to.get()
                        message, total = scan_my_ports(int(starting_port),
                                                       int(ending_port))
                        for i in message:
                            new_message = "My TCP " + i + "\n"
                            self.area.insert(0.0, new_message, ("ports"))
                            #self.area.tag_configure("ports", foreground = "green")

                    time = "The TCP port scan completed in: " + str(
                        total) + "\n"
                    self.area.insert(0.0, time, ("timing"))
                    self.area.tag_configure("timing", foreground="red")
                else:
                    self.area.insert(0.0, "No valid ports specified.")

            # Check to see if IP button is marked
            if self.ip.get() == 1:
                message = my_ip()
                self.area.insert(0.0, message)

            # Check if gateway button is marked.
            if self.gateway.get() == 1:
                message = my_gateway()
                self.area.insert(0.0, message)

            # Check if service button is marked.
            if self.service.get() == 1:
                message, time = scan_my_services()
                for i in message:
                    new_message = i + "\n"
                    self.area.insert(0.0, new_message)
                new_time = "The local scan completed in: " + str(time) + "\n"
                self.area.insert(0.0.new_time, ("timing"))
                self.area.tag_configure("timing", foreground="red")

        # If Scan other button is clicked.
        elif button_id == 2:

            # Check other IP's
            if self.ip.get() == 1:
                # Check the entry widgets.
                if self.ip_from:
                    if self.ip_to:
                        # Get the ranges from the entry widgets
                        starting_ipv4_address = self.ip_from.get()
                        ending_ipv4_address = self.ip_to.get()

                        # Pass the values from the entry widgets into the function to scan nearby IP addresses.
                        message, time = ping_ip_other(starting_ipv4_address,
                                                      ending_ipv4_address)
                        if message:
                            for i in message:
                                new_message = "The address:     {:>15} {:>15}".format(
                                    i, "is UP\n")
                                self.area.insert(0.0, new_message)

                        total_time = "Range scanned: " + str(
                            starting_ipv4_address) + " to " + str(
                                ending_ipv4_address
                            ) + "\n" + "The IP scan completed in:  " + str(
                                time) + "\n"
                        self.area.insert(0.0, total_time, ("timing"))
                        self.area.tag_configure("timing", foreground="red")

                else:
                    self.area.insert(0.0, "No Ip range is specified.")

            # Check others Ports
            if self.port.get() == 1:
                # Check port entry widgets.
                if self.port_from:
                    if self.port_to:
                        # Get the user input
                        starting_port = self.port_from.get()
                        ending_port = self.port_to.get()

                        message, time = scan_ports_other(
                            int(starting_port), int(ending_port))
                        if message:
                            for i in message:
                                new_msg = "The " + i + "\n"
                                self.area.insert(0.0, new_msg)
                        else:
                            new_msg = "Must scan nearby IP addresses first.\n"

                    total_time = "TCP Port scan completed in: " + str(
                        time) + "\n"
                    self.area.insert(0.0, total_time, ("timing"))
                    self.area.tag_configure("timing", foreground="red")

                else:
                    self.area.insert(0.0, "No Port range specified.")

            # Check other host names. Based on IP's scanned.
            if self.host.get() == 1:
                message, time = scan_host_other(ip_address_up)
                # Check that IP's of other computers were collected
                if message:
                    for i in message:
                        new_message = "Host name: " + str(i) + "\n"
                        self.area.insert(0.0, new_message)

                else:
                    new_msg = "Must scan nearby IP addresses first. \n"
                    self.area.insert(0.0, new_msg)

                total = "The host scan completed in: " + str(time) + "\n"
                self.area.insert(0.0, total, ("timing"))
                self.area.tag_configure("timing", foreground="red")

            # Check gateway return the gateway of the host machine again.
            if self.gateway.get() == 1:
                message = "\n" + str(my_gateway())
                self.area.insert(0.0, message)

            # Check what services are running on which IP and port.
            if self.service.get() == 1:
                message, time = services_other()
                if message:
                    for i in message:
                        new_message = i + "\n"
                        self.area.insert(0.0, new_message)

                else:
                    new_msg = "The IP addresses and ports must be scanned first."
                    self.area.insert(0.0, new_msg)

                new_time = "The service scan completed in: " + str(time) + "\n"
                self.area.insert(0.0, new_time, ("timing"))
                self.area.tag_configure("timing", foreground="red")

        else:
            pass
Ejemplo n.º 49
0
class Calculator(Frame):

    def __init__(self,parent):
        Frame.__init__(self,parent)
        self.parent = parent
        self.initUI()
        self.string = ""

    def initUI(self):
        self.parent.title("Calculator")
        Style().configure("TButton",padding = (0,5,0,5),font = 'serif 10')
        self.data = StringVar()
        self.columnconfigure(0,pad = 4)
        self.columnconfigure(1,pad =4)
        self.columnconfigure(2,pad = 4)
        self.columnconfigure(3,pad = 4)

        self.rowconfigure(0,pad = 4)
        self.rowconfigure(1,pad = 4)
        self.rowconfigure(2,pad = 4)
        self.rowconfigure(3,pad = 4)
        self.rowconfigure(4,pad = 4)

        self.entry = Entry(self,textvariable = self.data)
        self.entry.grid(row = 0,columnspan = 4,sticky = W+E)
        self.entry.focus_set()
        
        cls = Button(self,text = 'CLS',command = self.reset())
        cls.grid(row = 1,column = 0)
        bck = Button(self,text = 'Backspace',command = lambda: self.decrement())
        bck.grid(row = 1,column = 1, columnspan = 2,sticky = W+E)
        clo = Button(self,text = 'Close', command = lambda: self.close())
        clo.grid(row = 1,column = 3)
        
        sev = Button(self,text = '7',command = lambda: self.concat('7'))
        sev.grid(row = 2,column = 0)
        eig = Button(self,text = '8',command = lambda: self.concat('8'))
        eig.grid(row = 2,column = 1)
        nin = Button(self,text = '9',command = lambda: self.concat('9'))
        nin.grid(row = 2,column = 2)
        div = Button(self,text = '/',command = lambda: self.addop('/'))
        div.grid(row = 2,column = 3)
        
        fou = Button(self,text = '4',command = lambda: self.concat('4'))
        fou.grid(row = 3,column = 0)
        fiv = Button(self,text = '5',command = lambda: self.concat('5'))
        fiv.grid(row = 3,column = 1)
        six = Button(self,text = '6',command = lambda: self.concat('6'))
        six.grid(row = 3,column = 2)
        mul = Button(self,text = '*',command = lambda: self.addop('*'))
        mul.grid(row = 3,column = 3)
        
        one = Button(self,text = '1',command = lambda: self.concat('1'))
        one.grid(row = 4,column = 0)
        two = Button(self,text = '2',command = lambda: self.concat('2'))
        two.grid(row = 4,column = 1)
        thr = Button(self,text = '3',command = lambda: self.concat('3'))
        thr.grid(row = 4,column = 2)
        mns = Button(self,text = '-',command = lambda: self.addop('-'))
        mns.grid(row = 4,column = 3)
        
        zer = Button(self,text = '0',command = lambda: self.concat('0'))
        zer.grid(row = 5,column = 0)
        dot = Button(self,text = '.',command = lambda: self.concat('.'))
        dot.grid(row = 5,column = 1)
        equ = Button(self,text = '=',command = lambda: self.calculate())
        equ.grid(row = 5,column = 2)
        plu = Button(self,text = '+',command = lambda: self.addop('+'))
        plu.grid(row = 5,column = 3)
        self.pack()

    def addop(self, op):
        if '.' not in str(self.string):
            self.string = str(self.string)+str('.0')+str(op)
        else:
            self.string = str(self.string)+str(op)
        self.data.set(self.string)
        
    def calculate(self):
        self.string = self.data.get()
        self.string = calci(self.string)
        self.data.set(self.string)

    def concat(self,this):
        self.string = str(self.string)+str(this)
        self.data.set(self.string)

    def reset(self):
        self.string = ""
        self.data.set(self.string)

    def decrement(self):
        self.string = str(self.string)[0:len(str(self.string))-1]
        self.data.set(self.string)

    def close(self):
        self.parent.destroy()
Ejemplo n.º 50
0
	def initUI(self):

		self.parent.title("LINEARITY TEST FOR PMT BASES")
		self.pack(fill=BOTH, expand=True)

		self.columnconfigure(0, weight=1)
		#self.rowconfigure(0, weight=1)
		# weight attibute is used to make them growable

#		self.graph_cb   = BooleanVar()
		self.init_point = IntVar()
		self.base_path  = StringVar()
		self.end_point  = IntVar()
		self.step       = IntVar()
		self.n_meas     = IntVar()
		self.inc_point  = IntVar()
		self.coef       = DoubleVar()
		self.noise      = DoubleVar()
		self.thr_sigma  = DoubleVar()
		self.SPE_DAQ    =	 DoubleVar()	
		
		search = Image.open("next_logo.jpg")
		search_temp = search.resize((170, 200), Image.ANTIALIAS)
		search_aux = ImageTk.PhotoImage(search_temp)
		label1 = Label(self, image=search_aux)
		label1.image = search_aux
		label1.grid(row=0, column=0,
				columnspan=10, rowspan=10, sticky=E+W+S+N)

		#Text Box
		self.base_path.set("F:/DATOS_DAC/2052/pmt_0_trace_evt_")
		e1 = Entry(self, textvariable=self.base_path, width=40)
		e1.grid(row=1,column=2, sticky=W, columnspan=5, pady=5)
		e1_label = Label(self, text="DataSet path (including name file)")
		e1_label.grid(row=0,column=2,sticky=W, columnspan=5, pady=5)		
		
		#Spin Boxes
		self.n_meas.set("20")
		sb1 = Spinbox(self, from_=1, to=1000, 
				  width=6, textvariable=self.n_meas)
		sb1.grid(row=3,column=3, sticky=W)
		sb1_label = Label(self, text="Measurements")
		sb1_label.grid(row=2,column=3, padx=0, sticky=W)		
		
		self.step.set("10")
		sb2 = Spinbox(self, from_=10, to=200, 
				  width=6, textvariable=self.step)
		sb2.grid(row=3,column=4, sticky=W)
		sb2_label = Label(self, text="Pulse Width Step")
		sb2_label.grid(row=2,column=4, padx=0, sticky=W)
		
		# INTEGRATION LIMITS
		Integration_label = Label(self, text="INTEGRATION LIMITS",
		                          font = "Verdana 12 bold")
		Integration_label.grid(row=4,column=3, 
						padx=5,
						columnspan = 3, pady=10)
		self.init_point.set("30")
		sb3 = Spinbox(self, from_=1, to=10000, 
				  width=6, textvariable=self.init_point)
		sb3.grid(row=7,column=3, sticky=W)
		sb3_label = Label(self, text="Start (usec)")
		sb3_label.grid(row=6,column=3, padx=0, sticky=W)		
		
		self.end_point.set("160")
		sb4 = Spinbox(self, from_=1, to=10000, 
				  width=6, textvariable=self.end_point)
		sb4.grid(row=7,column=4, sticky=W)
		sb4_label = Label(self, text="End (usec)")
		sb4_label.grid(row=6,column=4, padx=0, sticky=W)

		
		# PARAMETERS
		Integration_label = Label(self, text="PARAMETERS",
		                          font = "Verdana 12 bold")
		Integration_label.grid(row=8,column=3, 
						padx=5,
						columnspan = 3, pady=10)
		self.inc_point.set("3")
		sb5 = Spinbox(self, from_=1, to=100, 
				  width=6, textvariable=self.inc_point)
		sb5.grid(row=11,column=3, sticky=W)
		sb5_label = Label(self, text="First point")
		sb5_label.grid(row=10,column=3, padx=0, sticky=W)
		
		self.coef.set("1.636E-3")
		e6 = Entry(self, width=10, textvariable=self.coef)
		e6.grid(row=11,column=4, sticky=W)
		e6_label = Label(self, text="DBLR Coef")
		e6_label.grid(row=10,column=4, sticky=W)
				
		self.noise.set("0.75")
		e7 = Entry(self, width=10, textvariable=self.noise)
		e7.grid(row=11,column=5, sticky=W)
		e7_label = Label(self, text="Noise (LSB)")
		e7_label.grid(row=10,column=5, sticky=W)

		self.thr_sigma.set("40")
		e8 = Entry(self, width=10, textvariable=self.thr_sigma)
		e8.grid(row=13,column=3, sticky=W)
		e8_label = Label(self, text="Threshold")
		e8_label.grid(row=12,column=3, sticky=W)
		
		self.SPE_DAQ.set("20.5")
		e9 = Entry(self, width=10, textvariable=self.SPE_DAQ)
		e9.grid(row=13,column=4, sticky=W)
		e9_label = Label(self, text="SPE (LSB)")
		e9_label.grid(row=12,column=4, sticky=W)		
		
		
#		#Check buttons
#		cb1 = Checkbutton(self, text="MultiGraph Output", variable=self.graph_cb					)
#		cb1.select()
#		cb1.grid(row=7,column=6, sticky=W)

		
		# Main buttons
		obtn = Button(self, text="GO!!", command=self.linearity_f)
		obtn.grid(row=14, column=4, sticky=E, pady=10)

		cbtn = Button(self, text="Quit", command=self.quit)
		cbtn.grid(row=14, column=5, sticky=E, pady=10)

		hbtn = Button(self, text="Help")
		hbtn.grid(row=14, column=0, sticky=W, pady=10)
class PAGUI(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Parameter Analyzer Control")
        self.style = Style()
        self.style.theme_use("clam")
        self.pack(fill=BOTH, expand=True)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        # self.rowconfigure(3, weight=1)
        # self.rowconfigure(5, pad=7)

        #set up instance variables
        self.directory = StringVar()
        self.fname = StringVar()
        self.fname_final = StringVar()
        self.device = StringVar()
        self.chip = StringVar()
        self.run = StringVar()

        self.toplabel = Label(self,
                              text="Dummy label at the top of the widget",
                              justify="center")
        self.bottomlabel = Label(
            self,
            text="for help/info see github.com/leobrowning92/pa-control",
            justify="center",
            font="arial 11 italic")

        self.directory_btn = Button(self,
                                    text="Directory",
                                    command=self.askdirectory)

        self.filename_btn = Button(self, text="Filename", command=self.askfile)

        # self.exit_btn = Button(self, text="Exit", command=self.quit)
        # self.exit_btn.grid(row=5, column=0, padx=5)

        self.update_btn = Button(self, text="Update", command=self.runUpdate)

        self.iterdevice_btn = Button(self,
                                     text="Iterate [device]",
                                     command=self.newDevice)

        self.iterchip_btn = Button(self,
                                   text="Iterate [chip]",
                                   command=self.newChip)
        self.iterrun_btn = Button(self,
                                  text="Iterate [run]",
                                  command=self.newRun)

        self.chip.set("001")
        self.chipnum_entry = Entry(self, textvariable=self.chip, width=5)

        self.device.set("01")
        self.devicenum_entry = Entry(self, textvariable=self.device, width=5)

        self.run.set("001")
        self.runnum_entry = Entry(self, textvariable=self.run, width=5)

        self.directory_entry = Entry(self, textvariable=self.directory)

        self.fname.set(
            'Chip[chip]_[device]_run[run]_somenotes_[INFO]_[time].csv')
        self.fname_final.set(
            make_fname_final(self.fname.get(), self.chip.get(),
                             self.device.get(), self.run.get()))

        self.fname_entry = Entry(self, textvariable=self.fname)

        self.fname_final_label = Label(self,
                                       textvariable=self.fname_final,
                                       justify="center",
                                       font="arial 11 italic")

        # this button runs pulldata with parameter set by
        # self.datatype, which stores the value of self.radbtn
        self.pulldata_btn = Button(self,
                                   text="Pull Data",
                                   command=self.pulldata)

        self.datarun_btn = Button(self,
                                  text="Run Data sweep",
                                  command=self.datarun)

        #datatype=1 => diode, datatype=2 => FET
        self.datatype = IntVar()
        self.datatype1_radiobutton = Radiobutton(self,
                                                 text='Diode (VF, IF)',
                                                 variable=self.datatype,
                                                 value=1)
        self.datatype2_radiobutton = Radiobutton(self,
                                                 text='FET (VG, VDS, ID, IG)',
                                                 variable=self.datatype,
                                                 value=2)

        #grid alignments of all widgets
        self.toplabel.grid(column=0, columnspan=3, sticky=W, pady=4, padx=5)

        self.directory_btn.grid(row=1, column=0)
        self.directory_entry.grid(row=1,
                                  column=1,
                                  columnspan=2,
                                  padx=5,
                                  sticky=E + W)

        self.filename_btn.grid(row=2, column=0)
        self.fname_entry.grid(row=2,
                              column=1,
                              columnspan=2,
                              padx=5,
                              sticky=E + W)
        self.fname_final_label.grid(row=3,
                                    column=1,
                                    columnspan=2,
                                    sticky=N + E + W,
                                    pady=4,
                                    padx=5)

        self.iterchip_btn.grid(row=4, column=0, sticky=N)
        self.chipnum_entry.grid(row=4, column=1, padx=5, sticky=W)

        self.iterdevice_btn.grid(row=5, column=0, sticky=N)
        self.devicenum_entry.grid(row=5, column=1, padx=5, sticky=W)

        self.iterrun_btn.grid(row=6, column=0, sticky=N)
        self.runnum_entry.grid(row=6, column=1, padx=5, sticky=W)

        self.update_btn.grid(row=7, column=0, padx=5)
        self.pulldata_btn.grid(row=7, column=3, padx=5, sticky=E)
        self.datarun_btn.grid(row=6, column=3, padx=5, sticky=E)

        self.datatype1_radiobutton.grid(row=7,
                                        column=1,
                                        padx=5,
                                        sticky=N + E + S)
        self.datatype2_radiobutton.grid(row=7,
                                        column=2,
                                        padx=5,
                                        sticky=N + W + S)
        self.bottomlabel.grid(row=8,
                              column=0,
                              columnspan=3,
                              sticky=W,
                              pady=4,
                              padx=5)

#action funcctions for the various buttons

    def newChip(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.chip.set(str((int(self.chip.get()) + 1)).zfill(3))
                self.device.set(str(1).zfill(2))
            except Exception as e:
                print(e)
            self.runUpdate()

    def newRun(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.run.set(str((int(self.run.get()) + 1)).zfill(3))
            except Exception as e:
                print(e)
            self.runUpdate()

    def newDevice(self):
        if self.fname.get() == '':
            self.askfile()
        else:
            try:
                self.device.set(str((int(self.device.get()) + 1)).zfill(2))
            except Exception as e:
                print(e)
            self.runUpdate()

    def runUpdate(self):
        self.fname_final.set(
            make_fname_final(self.fname.get(), self.chip.get(),
                             self.device.get(), self.run.get()))

    def askdirectory(self):
        """Returns a selected directoryname."""
        self.directory.set(tkFileDialog.askdirectory())

    def askfile(self):
        fullpath = tkFileDialog.askopenfilename()
        if "/" in fullpath:
            i = fullpath.rfind("/")
        if "\\" in fullpath:
            i = fullpath.rfind("\\")
        # self.fname_final.set(fullpath[i + 1:])
        self.fname.set(fullpath[i + 1:])

    def pulldata(self):
        self.runUpdate()
        if self.datatype.get() == 1:
            download_data(path=self.directory.get(),
                          filename=self.fname_final.get(),
                          values=['VF', 'IF'])
        elif self.datatype.get() == 2:
            download_data(path=self.directory.get(),
                          filename=self.fname_final.get(),
                          values=['VG', 'VDS', 'ID', 'IG'])

    def datarun(self):
        self.runUpdate()
        if self.datatype.get() == 1:
            print("oh no we havent written a script for that yet!")
        elif self.datatype.get() == 2:
            run_FET_series(self.fname_final.get(), self.directory.get())
Ejemplo n.º 52
0
    def initUI(self):
        Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.columnconfigure(3, pad=3)

        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)

        entry = Entry(self)
        entry.grid(row=0, columnspan=4, sticky=W + E)
        cls = Button(self, text="Cls")
        cls.grid(row=1, column=0)
        bck = Button(self, text="Back")
        bck.grid(row=1, column=1)
        lbl = Button(self)
        lbl.grid(row=1, column=2)
        clo = Button(self, text="Close")
        clo.grid(row=1, column=3)
        sev = Button(self, text="7")
        sev.grid(row=2, column=0)
        eig = Button(self, text="8")
        eig.grid(row=2, column=1)
        nin = Button(self, text="9")
        nin.grid(row=2, column=2)
        div = Button(self, text="/")
        div.grid(row=2, column=3)

        fou = Button(self, text="4")
        fou.grid(row=3, column=0)
        fiv = Button(self, text="5")
        fiv.grid(row=3, column=1)
        six = Button(self, text="6")
        six.grid(row=3, column=2)
        mul = Button(self, text="*")
        mul.grid(row=3, column=3)

        one = Button(self, text="1")
        one.grid(row=4, column=0)
        two = Button(self, text="2")
        two.grid(row=4, column=1)
        thr = Button(self, text="3")
        thr.grid(row=4, column=2)
        mns = Button(self, text="-")
        mns.grid(row=4, column=3)

        zer = Button(self, text="0")
        zer.grid(row=5, column=0)
        dot = Button(self, text=".")
        dot.grid(row=5, column=1)
        equ = Button(self, text="=")
        equ.grid(row=5, column=2)
        pls = Button(self, text="+")
        pls.grid(row=5, column=3)

        self.pack()
Ejemplo n.º 53
0
class Window(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.initUI()
        self.UIwithGrid()

    def initUI(self):  # creating gui
        self.frame1 = Frame(self)
        self.frame2 = Frame(self)
        self.frame3 = Frame(self)
        self.frame4 = Frame(self)
        self.frame5 = Frame(self)

        # created multiple frames

        self.label1 = Label(self.frame1,
                            text="COURSE PROGRAM ESTIMATOR",
                            font='Helvetica 25 bold',
                            background="SpringGreen3",
                            foreground="black")
        self.label2 = Label(self.frame1,
                            text="     Training Data: ",
                            font="Times 14")
        self.entry = Entry(self.frame1, width=65)
        self.entry.insert(
            0,
            'https://www.sehir.edu.tr/tr/duyurular/2017-2018-Akademik-Yili-Ders-Programi'
        )
        self.color = Label(
            self.frame1,
            text="                   ",
            background="red",
        )
        self.button = Button(self.frame1,
                             text="Fetch and Train",
                             command=self.fetch)
        self.label3 = Label(self.frame2,
                            text="Individual Courses:",
                            font='Helvetica 10 bold')
        self.label4 = Label(self.frame3,
                            text="     Top 3 Estimates:",
                            font='Helvetica 10 bold')
        self.coursesListbox = Listbox(self.frame2, width=30)
        self.label5 = Label(self.frame4,
                            text=" Accuracy Analysis \nBased on Programs: ",
                            font='Helvetica 10 bold')
        self.programsListbox = Listbox(self.frame4, width=30)
        self.estimatesListbox = Text(self.frame5, width=30, height=10)

        self.scrollbar1 = Scrollbar(self.frame2, orient=VERTICAL)
        self.scrollbar2 = Scrollbar(self.frame4, orient=VERTICAL)
        self.scrollbar3 = Scrollbar(self.frame5, orient=VERTICAL)
        self.scrollbar1.config(command=self.coursesListbox.yview)
        self.scrollbar2.config(comman=self.programsListbox.yview)
        self.scrollbar3.config(command=self.estimatesListbox.yview)
        self.coursesListbox.config(yscrollcommand=self.scrollbar1.set)
        self.programsListbox.config(yscrollcommand=self.scrollbar2.set)
        self.estimatesListbox.config(yscrollcommand=self.scrollbar3.set)

    def UIwithGrid(self):
        self.frame1.grid(row=1, column=2, sticky=N + S + E + W)
        self.frame2.grid(row=2, column=1, columnspan=2, sticky=W)
        self.frame3.grid(row=2, column=2, sticky=N + E)
        self.frame4.grid(row=3, column=1, columnspan=2, sticky=W, pady=5)
        self.frame5.grid(row=3, column=2, columnspan=2, sticky=E, pady=5)
        self.label1.grid(row=1, column=2, sticky=E + W)
        self.label2.grid(row=2, column=1, columnspan=2, pady=25, sticky=W)
        self.entry.grid(row=2, column=2, columnspan=2, sticky=E)
        self.color.grid(row=3, column=2, columnspan=2)
        self.button.grid(row=3, column=2, sticky=E, padx=90)
        self.label3.grid(row=1, column=1)
        self.coursesListbox.grid(row=2, column=1)
        self.label4.pack(in_=self.frame3, side='left')
        self.label5.grid(row=1, column=1)
        self.programsListbox.grid(row=2, column=1)
        self.estimatesListbox.grid(row=2, column=3, sticky=E)
        self.scrollbar1.grid(row=2, column=1, sticky=N + S + E)
        self.scrollbar2.grid(row=2, column=1, sticky=N + E + S)
        self.scrollbar3.grid(row=2, column=2, columnspan=2, sticky=N + S + E)
        self.pack()

    def fetch(self):  # fetching phase
        self.color.config(background='yellow')
        self.course_list = []
        self.update()
        url = self.entry.get()
        self.dataobj = Data()  # creating data obj
        self.dataobj.init_data(url)
        self.courses = self.dataobj.courselist.keys()  # getting keys
        self.courses.sort()  # sorting keys
        self.obj_list = []
        for i in self.courses:
            self.obj_list.append(self.dataobj.courselist[i])
        self.classifier_obj = docclass.naivebayes(docclass.getwords)
        for i in self.obj_list:  # TRANING PHASE
            self.classifier_obj.train(i.split_name.lower(), i.first_code)
        r1 = re.compile("(.*?)\s*\(")
        for i in self.courses:  # adding courses to listbox
            course_name = self.dataobj.courselist[i].name
            name = r1.match(course_name)
            if name != None:
                name1 = i + '' + '(' + name.group(1) + ')'
            else:
                name1 = i + ' ' + '(' + course_name + ')'
            self.coursesListbox.insert(END, name1)
        for z in self.courses:  # adding course category to other listbox
            if self.dataobj.courselist[z].first_code not in self.course_list:
                self.course_list.append(self.dataobj.courselist[z].first_code)

            code = self.dataobj.courselist[z].first_code
            if code not in self.programsListbox.get(0, END):
                self.programsListbox.insert(END, code)
        self.color.config(background='green')
        self.update()
        self.coursesListbox.bind('<<ListboxSelect>>', self.estimate)
        self.programsListbox.bind('<<ListboxSelect>>', self.analyze)

    def estimate(self, event):  # estimating phase
        try:
            for wid in self.frame3.winfo_children():
                wid.destroy()
            self.label4 = Label(self.frame3,
                                text="     Top 3 Estimates:",
                                font='Helvetica 10 bold')
            self.label4.pack(in_=self.frame3)
        except:
            print 'ERROR !!!!'
        widget = event.widget
        selection = widget.curselection()
        picked = widget.get(selection[0])
        x = picked.split('(')
        dict_ = {}
        for cat in self.course_list:  # getting estimating scores
            dict_[cat] = self.classifier_obj.prob(x[1], cat) * 10

        scores = dict_
        sorted_scores = sorted(scores.items(),
                               key=operator.itemgetter(1),
                               reverse=True)  # sorting dictionary
        top_3 = sorted_scores[0:3]  # getting top 3 scores
        print top_3
        dict_temp = {x[0].split(' ')[0]: top_3}
        m = 1
        for key, value in dict_temp.items():  # adding items as labels
            for i in value:
                department, score = i
                if department != key:  # checking if it is true estimation or not
                    color = 'red'
                else:
                    color = 'green'
                self.first_element = Label(self.frame3,
                                           text=department + ':' + str(score),
                                           font='Helvetica 15 bold',
                                           background=color,
                                           width=20)
                if m == 1:
                    self.first_element.pack(in_=self.frame3)
                elif m == 2:
                    self.first_element.pack(in_=self.frame3)
                elif m == 3:
                    self.first_element.pack(in_=self.frame3)
                m = m + 1

    def analyze(self, event):
        try:
            self.estimatesListbox.delete('1.0', END)
        except:
            print 'ERROR'
        widget = event.widget
        selection = widget.curselection()
        picked = widget.get(selection[0])
        cat_ = picked
        course_names = {}
        for i in self.obj_list:  # creating a dict. keys name of courses, values code of
            if i.first_code == cat_:  # filtering
                print i.first_code, cat_
                name = i.name.split('(')[0]
                course_names[name] = i.code
            else:
                continue
        info = {}
        for course in course_names.keys():  # finds best match for each course
            score_dict = {}
            for cat in self.course_list:
                score_dict[cat] = self.classifier_obj.prob(course, cat)
            sorted_scores = sorted(score_dict.items(),
                                   key=operator.itemgetter(1),
                                   reverse=True)
            info[course] = sorted_scores[0][0]
        all_info = {
            'Total Number Of Courses: ': str(len(info))
        }  # creating initial analyzing data
        q = 0
        for item in info.values():  # amount of accurate data
            if item != cat_:
                q = q + 1
        all_info['Inaccurate Classification: '] = str(q)
        all_info['Accurately Classified: '] = len(info) - q
        all_info['Accuracy: '] = '%' + str(
            (float(all_info['Accurately Classified: ']) / float(len(info))) *
            100)
        _ = all_info.keys()
        _.sort()
        for infos in _:
            self.estimatesListbox.insert(END,
                                         infos + str(all_info[infos]) + '\n ')

        for course_ in info:
            self.estimatesListbox.insert(
                END,
                '\t' + course_names[course_] + '-->' + info[course_] + '\n')
Ejemplo n.º 54
0
class CustomerFrame(Frame):
    def __init__(self, master, customers, output_text, refresh):
        Frame.__init__(self, master)
        self.output_text = output_text
        self.refresh = refresh
        self.root = master
        self.customers = customers

        self.name = StringVar() #edit customer
        self.names = []
        self.ncd = NewCustomerDialog(self.root, self.customers, self.refresh, edit=True)

        self.fname = StringVar()
        self.lname = StringVar()
        self.mname = StringVar()
        self.payment = StringVar()
        self.date = StringVar()
        self.iconname="New Customer"

        lf = LabelFrame(self, text="New Customer")
        lf.grid(padx=5,pady=5,row=0,column=0,sticky='ew')
        
        ### dialog content        
        Label(lf, text="Name: ").grid(row=0,column=0,sticky='e',padx=(10,0),pady=(10,2))
        Label(lf, text="Type: ").grid(row=1,sticky='e',pady=2,padx=(10,0))
        Label(lf, text="Date: ").grid(row=1,column=2,sticky='e',ipady=2,padx=(10,0))

        self.fname_en = Entry(lf, width=20, textvariable=self.fname)
        self.mname_en = Entry(lf, width=4, textvariable=self.mname)
        self.lname_en = Entry(lf, width=20, textvariable=self.lname)
        self.payment_cb = Combobox(lf, textvariable=self.payment, width=12,
                                   values=("Drop In", "Punch Card", "Monthly", "Inactive"))
        self.date_en = Entry(lf, width=15, textvariable=self.date)
        
        self.fname_en.grid(row=0,column=1,sticky='ew',pady=(10,2))
        self.mname_en.grid(row=0,column=2,sticky='ew',pady=(10,2))
        self.lname_en.grid(row=0,column=3,sticky='ew',padx=(0,10),pady=(10,2))
        self.payment_cb.grid(row=1,column=1,sticky='ew')
        self.date_en.grid(row=1,column=3,columnspan=2,sticky='ew',padx=(0,10))
        
        ### buttons
        Button(lf, text='Reset Values', width=15,
               command=self.reset_values).grid(row=3,column=0,columnspan=2,sticky='ew',padx=10,pady=(2,10))
        Button(lf, text='Submit', width=15,
               command=self.add_customer).grid(row=3,column=3,sticky='ew',padx=(0,10),pady=(2,10))

        for i in range(4):
            lf.columnconfigure(i, weight=1)

        # edit customer
        lf = LabelFrame(self, text="Edit Customer")
        lf.grid(padx=5,pady=5,row=1,column=0,sticky='ew')

        Label(lf, text="Name: ").grid(row=0,column=0,sticky='e',pady=10,padx=(10,0))
        self.name_cb = Combobox(lf, textvariable=self.name, width=30, values=self.names)
        self.name_cb.grid(row=0,column=1,sticky='ew',pady=10)
        Button(lf, text="Edit",width=15,command=self.edit).grid(row=0,column=2,sticky='ew',padx=10,pady=10)

        for i in range(3):
            lf.columnconfigure(i,weight=1)
        self.columnconfigure(0,weight=1)

        self.fname_en.focus_set() #cursor goes here when frame is created
        self.update_names()
        self.reset_values() #zero out all values in new customer

    def edit(self):
        old_name = str(self.name.get())
        parsed = old_name.split(' ',2)
        (line,row) = self.customers.find(parsed[2],parsed[0],parsed[1])
        
        self.ncd.show(line)
        self.refresh() #refresh the global refresh
        name = ' '.join([self.ncd.fname.get(),self.ncd.mname.get(),self.ncd.lname.get()])
        self.output_text("+ - Modified: " + old_name + ' (' + line[3] + ') -> ' + name + " (" + self.ncd.payment.get() + ")\n")

    def update_names(self):
        '''
        update names in edit Combobox
        '''
        self.populate_names()
        if len(self.names) == 0: self.names = ['']
        self.name_cb['values'] = self.names
        self.name_cb.current(0)

    def populate_names(self):
        try:
            clist = self.customers.get_list()
        except IOError:
            self.output_text("! - " + self.customers.filename + " open in another application.\n")
            return
        clist.sort(key = lambda x: ', '.join(x[0:3]).lower())
        self.names = []
        for line in clist:
            self.names.append(' '.join([line[1],line[2],line[0]]))

    def reset_values(self):
        self.fname.set('')
        self.mname.set('')
        self.lname.set('')
        # blow out the field every time this is created
        self.date.set(date.today().strftime("%m/%d/%Y"))
        self.payment_cb.set("Drop In")

    def add_customer(self, event=None):
        # validate and show errors
        if self.fname.get() == '':
            showerror("Error!", "First name field blank!")
        elif self.lname.get() == '':
            showerror("Error!", "Last name field blank!")
        elif self.mname.get() == '':
            showerror("Error!", "Middle initial field blank!")
        elif self.payment.get() not in ("Drop In", "Punch Card", "Monthly", "Inactive"):
            showerror("Error!", "Incorect Customer type!")
        elif not re.compile(r'[01]?\d/[0123]?\d/[12]\d{1,3}').search(self.date.get()):
            showerror("Error!", "Bad entry for date, use format mm/dd/yyyy")
        else:
            # do work
            name = ' '.join([self.fname.get(),self.mname.get(),self.lname.get()])
            old, row = self.customers.find(str(self.lname.get()).strip(), str(self.fname.get()).strip(),
                                           str(self.mname.get()).strip())
            new = [str(self.lname.get()).strip(), str(self.fname.get()).strip(), str(self.mname.get()).strip(),
                   str(self.payment.get()).strip(), datetime.strptime(self.date.get(), "%m/%d/%Y")]
            
            if not old: #add customer
                self.customers.add(new)
                self.output_text("+ - New Customer: " + name + " (" + self.payment.get() + ")\n")
                self.refresh()
            else:
                var = IntVar()
                
                diag = AlreadyExistsDialog(self.root, new, old, var)
                diag.show()
                if var.get() == 0: # edit
                    pass
                if var.get() == 1: # replace customer
                    self.customers.replace(row, new)
                    self.output_text("+ - Modified: " + name + " (" + self.payment.get() + ")\n")
                    self.refresh()
Ejemplo n.º 55
0
class GUI(Frame):
    def __init__(self, parent, register):
        Frame.__init__(self, parent, padding=(3, 3, 3, 3))
        self.parent = parent
        self.register = register
        self.logger = register.get_events_logger()
        self.init_ui()

        self.login()
        self.update_order()

    def login(self):
        logged_in = False
        while not logged_in:
            token = None
            while token is None:
                token = askstring(title="Please login", prompt="Login")
            try:
                self.register.login_employee(token)
                logged_in = True
            except CredentialException:
                self.logger.warning("invalid employee token '" + token +
                                    "', " + "unable to login")
        self.name_var.set(register.get_employee_name())
        # Put focus in barcode field
        self.barcode_field.focus()

    def logout(self, *args):
        self.register.logout_employee()
        self.name_var.set("")
        self.login()

    def print_count(self):
        try:
            print self.register.get_register_count()
        except CredentialException:
            self.logger.warning("insufficient privileges to print register " +
                                "count")
        # Put focus in barcode field
        self.barcode_field.focus()

    def add(self, token):
        try:
            self.register.add(token)
        except CredentialException:
            self.logger.warning("insufficient privileges to add an item")
        except ValueError:
            pass
        finally:
            self.update_order()
            # Put focus in barcode field
            self.barcode_field.focus()

    def add_custom(self, *args):
        name = askstring(title="Enter item name", prompt="Item name")
        if name is not None:
            price = askfloat(title="Enter item price",
                             prompt="Item price")
            if price is not None:
                try:
                    self.register.add_custom(name, price)
                except CredentialException:
                    self.logger.warning("insufficient privileges to add " +
                                        "a custom item")
                except ValueError as e:
                    self.logger.warning(e.__str__)
                finally:
                    self.update_order()
        # Put focus in barcode field
        self.barcode_field.focus()

    def remove(self, token):
        try:
            self.register.remove(token)
        except CredentialException:
            self.logger.warning("insufficient privileges to scan an item")
        except ValueError:
            self.logger.warning("token does not correspond to any item")
        except ItemNotFoundException:
            self.logger.warning("item not in order, unable to remove it")
        finally:
            self.update_order()
            # Put focus in barcode field
            self.barcode_field.focus()

    def clear_order(self, *args):
        try:
            self.register.clear_order()
        except CredentialException:
            self.logger.warning("insufficient privileges to clear the order")
        finally:
            self.update_order()
            # Put focus in barcode field
            self.barcode_field.focus()

    def adjust(self, *args):
        amount = askfloat(title="Enter adjustment amount",
                          prompt="Adjustment amount")
        if amount is not None:
            try:
                self.register.adjust(amount)
            except CredentialException:
                self.logger.warning("insufficient privileges to adjust " +
                                    "register count")
            except ValueError as e:
                self.logger.warning("invalid adjustment amount: " + e)
        # Put focus in barcode field
        self.barcode_field.focus()

    def checkout(self, *args):
        try:
            self.register.checkout_order()
        except CredentialException:
            self.logger.warning("insufficient privileges to checkout order")
        finally:
            self.update_order()
        # Put focus in barcode field
        self.barcode_field.focus()

    def count(self, *args):
        # TODO: implement a proper register count
        # TODO: add dialog box telling how register count went
        count = askfloat(title="Enter register count", prompt="Register count")
        if count is not None:
            try:
                self.register.count_register(count)
            except CredentialException:
                self.logger.warning("insufficient privileges to count " +
                                    "register")
        # Put focus in barcode field
        self.barcode_field.focus()

    def parse_barcode_field(self, event):
        command = self.barcode_field.get().strip()
        self.barcode_var.set("")
        tokens = command.split(" ")
        if tokens[0] == "print_count":
            self.print_count()
        elif tokens[0] == "print_order":
            self.print_order()
        elif tokens[0] == "remove":
            if len(tokens) < 2:
                self.logger.warning("need an item to remove")
                return None
            self.remove(tokens[1])
        elif tokens[0] == "adjust_count":
            if len(tokens) < 2:
                self.logger.warning("need an adjustment amount")
                return None
            self.adjust(tokens[1])
        elif tokens[0] == "custom":
            if len(tokens) < 3:
                self.logger.warning("need an name and a price")
                return None
            try:
                self.add_custom(tokens[1], float(tokens[2]))
            except ValueError:
                self.logger.warning("price is not valid")
        elif tokens[0] == "checkout":
            self.checkout()
        elif tokens[0] == "count":
            if len(tokens) < 2:
                self.logger.warning("need an register count")
                return None
            else:
                self.count(tokens[1])
        else:
            if tokens[0] != "":
                self.add(tokens[0])
        # Put focus in barcode field
        self.barcode_field.focus()

    def update_order(self):
        self.items_var.set(tuple(
            item.get_name() + " x " + str(quantity) for
            item, quantity in self.register.get_order().items()))
        self.total_var.set("Total: %0.2f$" % self.register.get_order_total())
        # Put focus in barcode field
        self.barcode_field.focus()

    def init_ui(self):
        # Window configuration
        screen_width = self.parent.winfo_screenwidth()
        screen_height = self.parent.winfo_screenheight()
        self.parent.geometry(
            '%dx%d+%d+%d' % (screen_width, screen_height, 0, 0))
        self.parent.title("Caisse Planck")
        self.parent.rowconfigure(0, weight=1)
        self.parent.columnconfigure(0, weight=1)

        self.grid(column=0, row=0, sticky=(N, S, E, W))
        self.rowconfigure(0, weight=0)
        self.rowconfigure(1, weight=1)
        self.rowconfigure(2, weight=1)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(4, weight=1)
        self.rowconfigure(7, weight=0)
        self.rowconfigure(8, weight=0)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=0)
        self.columnconfigure(2, weight=0)

        self.items_var = StringVar()
        self.items_list = Listbox(self, height=10, listvariable=self.items_var)
        self.items_list.grid(row=1, column=0, rowspan=8, sticky=(N, S, E, W))

        self.barcode_var = StringVar(self)
        self.barcode_field = Entry(self, textvariable=self.barcode_var)
        self.barcode_field.bind("<Return>", self.parse_barcode_field)
        self.barcode_field.grid(row=0, column=0, sticky=(N, E, W))

        self.benevole_label = Label(self, text="Volunteer:")
        self.benevole_label.grid(row=0, column=1, sticky=(N, W))

        self.name_var = StringVar(self)
        self.name_label = Label(self, textvar=self.name_var)
        self.name_label.grid(row=0, column=2, sticky=(N, W))


        self.parent.bind("<F1>", self.logout)
        self.logout_button = Button(self, text="Logout (F1)",
                                    command=self.logout)
        self.logout_button.grid(row=1, column=1, columnspan=2, sticky=(E, W))

        self.parent.bind("<F5>", self.count)
        self.count_button = Button(self, text="Count register (F5)",
                                   command=self.count)
        self.count_button.grid(row=2, column=1, columnspan=2, sticky=(E, W))

        self.parent.bind("<F6>", self.adjust)
        self.adjust_button = Button(self, text="Register adjustment (F6)",
                                    command=self.adjust)
        self.adjust_button.grid(row=3, column=1, columnspan=2, sticky=(E, W))

        self.parent.bind("<F6>", self.add_custom)
        self.custom_item_button = Button(self, text="Custom item (F7)",
                                         command=self.add_custom)
        self.custom_item_button.grid(row=4, column=1, columnspan=2,
                                     sticky=(E, W))

        self.total_var = StringVar(self, value="Total: 0.00$")
        self.total_label = Label(self, textvar=self.total_var)
        self.total_label.grid(row=7, column=1, columnspan=2, sticky=(S, E, W))

        self.parent.bind("<F12>", self.checkout)
        self.ok_button = Button(self, text="Ok (F12)", command=self.checkout)
        self.ok_button.grid(row=8, column=1, sticky=(S, E, W))

        self.parent.bind("<Escape>", self.clear_order)
        self.cancel_button = Button(self, text="Cancel (ESC)",
                                    command=self.clear_order)
        self.cancel_button.grid(row=8, column=2, sticky=(S, E, W))
Ejemplo n.º 56
0
Archivo: pySAD.py Proyecto: AlbMA/PySAD
class Principal(Frame):

    # Class for helping Tooltips
    class ToolTip(object):
        def __init__(self, widget):
            self.widget = widget
            self.tipwindow = None
            self.id = None
            self.x = self.y = 0

        def showtip(self, text, lang):
            self.text = text
            if self.tipwindow or not self.text:
                return
            x, y, cx, cy = self.widget.bbox("insert")
            x = x + self.widget.winfo_rootx() + 27
            y = y + cy + self.widget.winfo_rooty() + 27
            self.tipwindow = tw = Toplevel(self.widget)
            tw.wm_overrideredirect(1)
            tw.wm_geometry("+%d+%d" % (x, y))
            try:
                # For Mac OS
                tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
                           "help", "noActivates")
            except TclError:
                pass
            label = Label(tw,
                          text=self.text[lang],
                          justify=LEFT,
                          background="#ffffe0",
                          relief=SOLID,
                          borderwidth=1,
                          font=("tahoma", "8", "normal"))
            label.pack(ipadx=1)

        def hidetip(self):
            tw = self.tipwindow
            self.tipwindow = None
            if tw:
                tw.destroy()

    # Initialization function
    def __init__(self, parent):

        Frame.__init__(self, parent)

        self.parent = parent

        # Spiral parameters (defined as StringVars for convenience)
        self.a = StringVar()
        self.a.set('0')

        self.b = StringVar()
        self.b.set('0.5')

        self.c = StringVar()
        self.c.set('1')

        self.lMax = StringVar()
        self.lMax.set(158)

        self.frec = StringVar()
        self.frec.set(500)

        self.StringLongitud = StringVar()
        self.StringRadio = StringVar()

        # Help mode flag
        self.ayuda = False

        # Figure object
        self.f = Figure(figsize=(5, 5))

        self.initUI()

    # Tooltip creator function (allowed by help mode flag)
    def createToolTip(self, widget, text):
        toolTip = self.ToolTip(widget)

        def enter(event):
            if self.ayuda:
                toolTip.showtip(text, self.lang)

        def leave(event):
            toolTip.hidetip()

        widget.bind('<Enter>', enter)
        widget.bind('<Leave>', leave)

    # Euclidean distance calculator function
    def distancia(self, r1, phi1, r2, phi2):
        return sqrt(r1**2 + r2**2 - 2 * r1 * r2 * cos(phi1 - phi2))

    # Polar to Cartesian coordinates
    def pol2cart(self, rho, phi):
        x = rho * cos(phi)
        y = rho * sin(phi)
        return (x, y)

    #
    def grafico(self):

        # Set figure size
        self.f = Figure(figsize=(5, 5))

        # Check whether negative parameters are present and show an error
        if float(self.c.get()) < 0 or float(self.b.get()) < 0:
            print self.lang
            tkMessageBox.showerror("Error", self.error.get())
            return

        # Set figure axis
        ax = self.f.add_subplot(111, polar=True)

        # Initialize r and theta lists at the center point
        self.theta_disc = [0]
        self.r_disc = [0]
        self.theta_disc_n = [0]

        # Initialize length value and list
        l = 0
        l_vec = []

        # Loop limited by antenna length
        while l < int(self.lMax.get()):

            # Length of each antenna segment in cm, computed as 1/15 of the wave length
            lseg = 300 / float(self.frec.get()) * 100 / 15

            if self.tipoCurva.get() == 1:
                # Archimedean spiral

                # New theta values are calculated according to the following:
                # In an Archimedean spiral
                # 		          /r  -  a\ c
                # 		theta  =  |-------|
                # 		          \   b   /

                # In order to get an approximately equally spaced segments, new theta values are computed according to the next formula. This formula has been worked
                # out gradually, not basing on any well-known expression.
                # 		                          /0.5 * lseg  -  a\ c
                # 		                          |----------------|    -  lseg
                # 		                          \        b       /
                # 		                          ------------------------------  +  lseg
                # 		                                 10 * theta   +  1
                # 		                                           n
                # 		theta       =  theta   +  ---------------------------------------
                # 		     n + 1          n                    r   +  1
                # 		                                          n

                self.theta_disc.append(self.theta_disc[-1] + \
                 (( ((0.5*lseg - float(self.a.get()))/float(self.b.get()))**(float(self.c.get())) - lseg) / (10*self.theta_disc[-1] + 1) + lseg) \
                  / (self.r_disc[-1] + 1))
                # print str(lseg)
                # print str(self.r_disc[-1])
            else:
                # print "Eh: " + str(self.theta_disc[-1])
                # print "Ra: " + str(self.r_disc[-1])
                # print "Ls: " + str(lseg)
                # print "Ot: " + str(log(0.5*lseg/float(self.a.get()))/float(self.b.get()))
                self.theta_disc.append(self.theta_disc[-1] + \
                 (( max(log(0.5*lseg/float(self.a.get()))/float(self.b.get()),float(self.a.get())) - lseg) * exp(-1*self.theta_disc[-1]) + lseg) \
                  / (self.r_disc[-1] + 1))
                #print str(lseg)
                #print str(self.r_disc[-1])

            if self.tipoCurva.get() == 1:
                self.r_disc.append(
                    float(self.b.get()) *
                    self.theta_disc[-1]**(1 / float(self.c.get())) +
                    float(self.a.get()))
            elif self.tipoCurva.get() == 2:
                self.r_disc.append(
                    float(self.a.get()) *
                    exp(float(self.b.get()) * self.theta_disc[-1]))

            self.theta_disc_n.append(pi + self.theta_disc[-1])

            l_vec.append(
                self.distancia(self.r_disc[-1], self.theta_disc[-1],
                               self.r_disc[-2], self.theta_disc[-2]))

            l += l_vec[-1]

        if self.fuente.get() and str(
                self.checkFuente.cget('state')) == 'normal':
            self.theta_disc.remove(0)
            self.r_disc.remove(0)
            self.theta_disc_n.remove(0)
            ax.plot([self.theta_disc[0], self.theta_disc_n[0]],
                    [self.r_disc[0], self.r_disc[0]],
                    color='r')
            ax.plot([0], [0], color='m', marker='o', markersize=5)

        self.StringLongitud.set("%#.1f cm" % l)
        self.StringRadio.set("%#.1f cm" % max(self.r_disc))

        ax.plot(self.theta_disc,
                self.r_disc,
                color='b',
                marker='.',
                markersize=4)
        if self.espejar.get():
            ax.plot(self.theta_disc_n,
                    self.r_disc,
                    color='g',
                    marker='.',
                    markersize=4)

        ax.set_rmax(max(self.r_disc))
        ax.grid(True)

        #with open('distancias.csv', 'wb') as f:
        #	writer = csv.writer(f)
        #	writer.writerows(izip(self.theta_disc, l_vec))

    def regraficar(self):
        self.grafico()
        self.canvas.get_tk_widget().pack_forget()
        self.canvas = FigureCanvasTkAgg(self.f, master=self.frame2)
        #canvas.show()
        self.canvas.get_tk_widget().pack(side=TOP,
                                         fill=BOTH,
                                         expand=1,
                                         padx=10,
                                         pady=10)

    def cambiaFormula(self):
        curvas = [
            '''R0lGODlhbAAWAOMPAAwMDLa2thYWFiIiIlBQUJ6enubm5gQEBGJiYszMzEBAQDAwMHR0dIqKigAAAP///yH5BAEKAA8ALAAAAABsABYAAAT+8MlJq7046817ToYnjmRpXsqpriw3JGgrz2pDHHDFFHTvezjL4kcsWoKUBIHCQDQQxmhy4EhZDATGkoKcEHIPwjIBkJoljsZVEFIwuGDJUJJwhM7ngN0i4D0YcxJdDwVqEg0CeC0DHQhlOokSCJGCcVYSAYyHiiaaGwOXEwCGDwqRBQgOC28PBqEPCAgMDDANgH8MCnEzAQSxCFufHQ6xuSF6FACeFgwBG1AHCwYGaSgC19jZAssViHQOrMIbelsIQwoHCuoLDsFCGwUgDn67LXVgDvUX3BeOEw0OHgCAcmgeBgME4QUssoBSgQMe+Am5lOqBQQkKHq0gIHEGMS9yHU1lO6CN34FwDamBOZBQhYCWGERqyyaxjp8HLyNuoOYMDYI6//awcNDzh0oJ1HiEy9CRwsIHDSBanCBg6YkCT4kA8EPAToGiTDkIgGEAQM8XsAKtuGUkgRsoYqxiaDrBbS4wbmNx2iuBLt+/HNQCfhABADs=''',
            '''R0lGODlhQwASAOMPAAwMDLa2thYWFiIiIlBQUJ6enubm5gQEBGJiYszMzEBAQDAwMHR0dIqKigAAAP///yH5BAEKAA8ALAAAAABDABIAAATn8MlJq70463ZSJQyhjWSpGUe1BM/imXCcNQvVDNLQyHz/KAOGgiXYPQAsn7IEKDwKg4SDgCA4DMtsBiVpCAqALk5LrhRqPwIt5yy7H4GaAWBIKJ7391uBULyoIhMNDDUMQi9uAVQIVRQJCAyMMAgPBwsGBg5GFAoCnp+gAmMXXhJSDBOEE3kkBQmZbYhkUogOLwEHWHCBJgUOehMLAhMFKTlBkG0wBKN6DpQSzBMOqD4C0BmdoaHNE1LK1xKwSg5Jepkv46gOyk+yGr7AE03RVwUsCrwF1SWq8g92Ij0gAGIClUjmSEQAADs=''',
            ''''''
        ]
        formula = PhotoImage(data=curvas[self.tipoCurva.get() - 1])
        self.formulaLabel.configure(image=formula)
        self.formulaLabel.image = formula

        if self.tipoCurva.get() == 1:
            self.parC.config(state=NORMAL)
            self.labelC.config(state=NORMAL)
        else:
            self.parC.config(state=DISABLED)
            self.labelC.config(state=DISABLED)

    def activarFuente(self):
        if self.espejar.get():
            self.checkFuente.config(state=NORMAL)
        else:
            self.checkFuente.config(state=DISABLED)

    def escribirFichero(self):
        tipoCurva = ['Arq', 'Log']
        c = [self.c.get() + ' ', '']

        self.file_opt = options = {}
        options['defaultextension'] = '.nec'
        options['filetypes'] = [('NEC2 files', '.nec'), ('all files', '.*')]
        options['initialdir'] = '~/Documentos/Antenas/Espirales'
        options['initialfile'] = 'Spiral ' + tipoCurva[int(self.tipoCurva.get())-1] + ' ' + \
               self.a.get() + ' ' + self.b.get() + ' ' + c[int(self.tipoCurva.get())-1] + self.lMax.get() + ' ' + self.frec.get() + '.nec'
        options['parent'] = self.parent
        options['title'] = 'Save NEC'

        fich = tkFileDialog.asksaveasfile(mode='w', **self.file_opt)

        r_final = list(reversed(self.r_disc)) + self.r_disc
        theta_final = list(reversed(self.theta_disc_n)) + self.theta_disc

        x_ant, y_ant = self.pol2cart(r_final[0], theta_final[0])

        tipoCurvaExt = ['Archimedean', 'Logarithmic']
        fich.write('CM Created with PySAD\n')
        fich.write('CM L = %#.1f\n' % float(self.lMax.get()))
        fich.write('CM ' + tipoCurvaExt[int(self.tipoCurva.get()) - 1] +
                   ' spiral')
        fich.write('CM a = ' + self.a.get())
        fich.write('CM b = ' + self.b.get())
        if int(self.tipoCurva.get()) == 0:
            fich.write('CM c = ' + self.c.get())
        fich.write('CE\n')

        print len(r_final)

        for i in range(len(r_final) - 1):
            x, y = self.pol2cart(r_final[i + 1], theta_final[i + 1])
            linea = 'GW\t%#d\t%#d\t%#.5f\t%#.5f\t%#.5f\t%#.5f\t%#.5f\t%#.5f\t%#.5f\n' % (
                i + 1, 1, x_ant / 100, y_ant / 100, 0, x / 100, y / 100, 0,
                0.001)
            fich.write(linea)
            x_ant, y_ant = x, y

        fich.write('GE\t0\nGN\t-1\nEK\n')
        fich.write('EX\t%#d\t%#d\t%#d\t%#d\t%#d\t%#d\n' %
                   (0, len(r_final) / 2, 1, 0, 1, 0))
        fich.write('FR\t0\t0\t0\t0\t299.8\t0\nEN')

        fich.close()

    def escribirPDF(self):
        tipoCurva = ['Arq', 'Log']
        c = [self.c.get() + ' ', '']
        self.file_opt = options = {}
        options['defaultextension'] = '.pdf'
        options['filetypes'] = [('PDF files', '.pdf'), ('all files', '.*')]
        options['initialdir'] = '~'
        options['initialfile'] = 'Spiral ' + tipoCurva[int(self.tipoCurva.get())-1] + ' ' + \
               self.a.get() + ' ' + self.b.get() + ' ' + c[int(self.tipoCurva.get())-1] + self.lMax.get() + ' ' + self.frec.get() + '.nec'
        options['parent'] = self.parent
        options['title'] = 'Save PDF'

        fich = tkFileDialog.asksaveasfile(mode='w', **self.file_opt)

        #self.f.axis('off')
        matplotlib.rcParams.update({'font.size': 1})

        self.f.gca().axes.get_xaxis().set_visible(False)
        self.f.gca().axes.get_yaxis().set_visible(False)

        papeles_w = [21, 29.7, 42, 59.4, 84.1]
        papeles_h = [29.7, 42, 59.4, 84.1, 118.9]

        for i_pap in range(0, len(papeles_w) - 1):
            if 2 * max(self.r_disc) < papeles_w[i_pap]:
                break

        print i_pap

        self.f.set_size_inches(papeles_w[i_pap] / 2.54,
                               papeles_h[i_pap] / 2.54)
        noMargen = dict(pad=72 * (papeles_w[i_pap] - 2 * max(self.r_disc)) /
                        2 / 2.54,
                        h_pad=0,
                        w_pad=0)
        self.f.set_tight_layout(noMargen)
        self.f.suptitle('test title')
        self.f.savefig(fich, format='pdf', dpi='90')
        fich.close()

    def mostrarAyuda(self):
        self.ayuda = not self.ayuda
        if self.ayuda:
            self.helpButton.state(["pressed"])
            self.config(cursor="question_arrow")
        else:
            self.helpButton.state(["!pressed"])
            self.config(cursor="")

    def initText(self):
        self.curTip = StringVar()
        self.ArcSpi = StringVar()
        self.LogSpi = StringVar()
        self.aaa = StringVar()
        self.bbb = StringVar()
        self.ccc = StringVar()
        self.Lma = StringVar()
        self.fre = StringVar()
        self.Mir = StringVar()
        self.Sou = StringVar()
        self.Gen = StringVar()
        self.lenlen = StringVar()
        self.radrad = StringVar()
        self.error = StringVar()

    def updateText(self, lang):

        self.lang = lang

        if lang == 0:
            self.espButton.state(["pressed"])
            self.engButton.state(["!pressed"])
        else:
            self.engButton.state(["pressed"])
            self.espButton.state(["!pressed"])

        self.stringText = {
            'curTip': ["Tipo de curva", "Curve type"],
            'ArcSpi': ["Espiral de Arquímedes", "Archimedean spiral     "],
            'LogSpi': ["Espiral logarítmica", "Logarithmic spiral"],
            'aaa': ["a (cm)", "a (cm)"],
            'bbb': ["b (cm/rad)", "b (cm/rad)"],
            'ccc': ["c", "c"],
            'Lma': ["Lmax (cm)", "Lmax (cm)"],
            'fre': ["frec (MHz)", "freq (MHz)"],
            'LmaToo': [
                "Longitud máxima de cada brazo de la antena",
                "Maximum length of each antenna's branch"
            ],
            'FreToo': [
                "Frecuencia de diseño (aumentar para disminuir la longitud de los segmentos)",
                "Design frequency (increase for decreasing segment length)"
            ],
            'Mir': ["Espejar", "Mirror"],
            'MirToo': [
                "Crea otra rama de la espiral girada 180º",
                "Create another spiral branch, twisted 180º"
            ],
            'Sou': ["Colocar fuente", "Put source"],
            'SouToo': [
                "Une las dos mitades y crea una fuente NEC2 en el centro",
                "Join both halves and create a NEC2 source at the middle"
            ],
            'Gen': ["Generar", "Generate"],
            'GenToo': [
                "Genera la espiral con los parámetros indicados",
                "Generate spiral following given parameters"
            ],
            'NEC': ["NEC", "NEC"],
            'NECToo': [
                "Guarda la espiral como archivo NEC2",
                "Save the spiral as a NEC2 file"
            ],
            'PDF': ["PDF", "PDF"],
            'PDFToo': [
                "Imprime la espiral a tamaño real en un documento PDF (máximo A0)",
                "Print the real sized spiral into a PDF document (A0 maximum)"
            ],
            'HHH': ["H", "H"],
            'lenlen': ["Longitud:", "Length:"],
            'radrad': ["Radio:", "Radius:"],
            'error': [
                "No se permiten valores negativos de b o c",
                "Negative values of b or c are not allowed"
            ]
        }

        self.curTip.set(self.stringText['curTip'][self.lang])
        self.ArcSpi.set(self.stringText['ArcSpi'][self.lang])
        self.LogSpi.set(self.stringText['LogSpi'][self.lang])
        self.aaa.set(self.stringText['aaa'][self.lang])
        self.bbb.set(self.stringText['bbb'][self.lang])
        self.ccc.set(self.stringText['ccc'][self.lang])
        self.Lma.set(self.stringText['Lma'][self.lang])
        self.fre.set(self.stringText['fre'][self.lang])
        self.Mir.set(self.stringText['Mir'][self.lang])
        self.Sou.set(self.stringText['Sou'][self.lang])
        self.Gen.set(self.stringText['Gen'][self.lang])
        self.lenlen.set(self.stringText['lenlen'][self.lang])
        self.radrad.set(self.stringText['radrad'][self.lang])
        self.error.set(self.stringText['error'][self.lang])

    def initUI(self):

        self.initText()

        self.parent.title("PySAD")
        self.style = Style()
        self.style.theme_use("clam")

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

        barraLateral = Frame(self, borderwidth=1)
        barraLateral.pack(side=RIGHT, padx=5, pady=5)

        idiomaFrame = Frame(barraLateral, relief=FLAT)
        idiomaFrame.pack(side=TOP)

        self.espButton = Button(idiomaFrame,
                                text="es",
                                width=0,
                                command=lambda: self.updateText(0))
        self.espButton.grid(row=0, column=0)
        self.engButton = Button(idiomaFrame,
                                text="en",
                                width=0,
                                command=lambda: self.updateText(1))
        self.engButton.grid(row=0, column=1)

        self.updateText(0)

        editarFrame = Frame(barraLateral,
                            relief=RAISED,
                            borderwidth=1,
                            width=1000)
        editarFrame.pack(fill=BOTH, expand=1, side=TOP, padx=5, pady=5)

        self.tipoCurva = IntVar()

        tituloSelector = Label(editarFrame, textvariable=self.curTip)
        tituloSelector.grid(row=0, columnspan=2, padx=2, pady=4)
        Radiobutton(editarFrame,
                    textvariable=self.ArcSpi,
                    variable=self.tipoCurva,
                    value=1,
                    command=self.cambiaFormula,
                    width=17).grid(row=1, columnspan=2, sticky=W, padx=4)
        Radiobutton(editarFrame,
                    textvariable=self.LogSpi,
                    variable=self.tipoCurva,
                    value=2,
                    command=self.cambiaFormula).grid(row=2,
                                                     columnspan=2,
                                                     sticky=W,
                                                     padx=4)

        self.formulaLabel = Label(editarFrame)
        self.formulaLabel.grid(row=4, columnspan=2, pady=4)

        Label(editarFrame, textvariable=self.aaa).grid(row=5, column=0, pady=2)
        Label(editarFrame, textvariable=self.bbb).grid(row=6, column=0, pady=2)
        self.labelC = Label(editarFrame, textvariable=self.ccc)
        self.labelC.grid(row=7, column=0, pady=2)
        self.labelC.config(state=DISABLED)
        Label(editarFrame, textvariable=self.Lma).grid(row=8, column=0, pady=2)
        Label(editarFrame, textvariable=self.fre).grid(row=9, column=0, pady=2)

        parA = Entry(editarFrame, width=4, textvariable=self.a)
        parA.grid(row=5, column=1, sticky=W)

        parB = Entry(editarFrame, width=4, textvariable=self.b)
        parB.grid(row=6, column=1, sticky=W)

        self.parC = Entry(editarFrame, width=4, textvariable=self.c)
        self.parC.grid(row=7, column=1, sticky=W)
        self.parC.config(state=DISABLED)

        lMax = Entry(editarFrame, width=4, textvariable=self.lMax)
        lMax.grid(row=8, column=1, sticky=W)
        self.createToolTip(lMax, self.stringText['LmaToo'])

        frec = Entry(editarFrame, width=4, textvariable=self.frec)
        frec.grid(row=9, column=1, sticky=W)
        self.createToolTip(frec, self.stringText['FreToo'])

        self.espejar = IntVar()
        checkEspejar = Checkbutton(editarFrame,
                                   textvariable=self.Mir,
                                   variable=self.espejar,
                                   command=self.activarFuente)
        checkEspejar.grid(row=10, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(checkEspejar, self.stringText['MirToo'])

        self.fuente = IntVar()
        self.checkFuente = Checkbutton(editarFrame,
                                       textvariable=self.Sou,
                                       state=DISABLED,
                                       variable=self.fuente)
        self.checkFuente.grid(row=11, columnspan=2, pady=2, sticky=W, padx=4)
        self.createToolTip(self.checkFuente, self.stringText['SouToo'])

        okButton = Button(editarFrame,
                          textvariable=self.Gen,
                          command=self.regraficar)
        okButton.grid(row=12, columnspan=2, pady=5)
        self.createToolTip(okButton, self.stringText['GenToo'])

        self.frame2 = Frame(self, borderwidth=1)
        self.frame2.pack(fill=BOTH, expand=1, side=LEFT, padx=5, pady=5)

        self.canvas = FigureCanvasTkAgg(self.f, master=self.frame2)
        self.canvas.get_tk_widget().pack(side=TOP,
                                         fill=BOTH,
                                         expand=1,
                                         padx=10,
                                         pady=10)

        frameGuardar = Frame(barraLateral, relief=FLAT, borderwidth=1)
        frameGuardar.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        icGuardar = PhotoImage(
            data=
            '''R0lGODlhEAAQAIABADMzM////yH5BAEKAAEALAAAAAAQABAAAAIlDI55wchvQJQOxontUktTbkHcSJZkGCao161N5U5SLNM1vZlOAQA7'''
        )
        saveButtonNEC = Button(frameGuardar,
                               text=self.stringText['NEC'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirFichero,
                               width=3)
        saveButtonNEC.image = icGuardar
        saveButtonNEC.grid(row=0, column=0, pady=2, padx=2, sticky=W)
        self.createToolTip(saveButtonNEC, self.stringText['NECToo'])

        saveButtonPDF = Button(frameGuardar,
                               text=self.stringText['PDF'][0],
                               image=icGuardar,
                               compound=LEFT,
                               command=self.escribirPDF,
                               width=3)
        saveButtonPDF.image = icGuardar
        saveButtonPDF.grid(row=0, column=2, pady=2, padx=2, sticky=E)
        self.createToolTip(saveButtonPDF, self.stringText['PDFToo'])

        self.helpButton = Button(frameGuardar,
                                 text="?",
                                 command=self.mostrarAyuda,
                                 width=2)
        self.helpButton.grid(row=0, column=3, pady=2, padx=2, sticky=E)

        frame3 = Frame(barraLateral, relief=RAISED, borderwidth=1)
        frame3.pack(fill=BOTH, expand=1, side=BOTTOM, padx=5, pady=5)

        Label(frame3, textvariable=self.lenlen).grid(row=1,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.radrad).grid(row=2,
                                                     column=0,
                                                     pady=4,
                                                     padx=12)
        Label(frame3, textvariable=self.StringLongitud).grid(row=1,
                                                             column=1,
                                                             pady=4)
        Label(frame3, textvariable=self.StringRadio).grid(row=2,
                                                          column=1,
                                                          pady=4)

    def onExit(self):
        self.quit()
Ejemplo n.º 57
0
frame = Frame(the_window)

Style().configure("TButton", padding=(0, 5, 0, 5), font='serif 10')

frame.columnconfigure(0, pad=3)
frame.columnconfigure(1, pad=3)
frame.columnconfigure(2, pad=3)
frame.columnconfigure(3, pad=3)

frame.rowconfigure(0, pad=3)
frame.rowconfigure(1, pad=3)
##  ENTRY  ###
band1Label = Label(frame, text='Band 1')
band1Label.grid(row=0, column=0)
band1Entry = Entry(frame)
band1Entry.grid(row=0, column=1)
band2Label = Label(frame, text='Band 2')
band2Label.grid(row=0, column=2)
band2Entry = Entry(frame)
band2Entry.grid(row=0, column=3)
band3Label = Label(frame, text='Band 3')
band3Label.grid(row=1, column=0)
band3Entry = Entry(frame)
band3Entry.grid(row=1, column=1)
band4Label = Label(frame, text='Band 4')
band4Label.grid(row=1, column=2)
band4Entry = Entry(frame)
band4Entry.grid(row=1, column=3)

CatalogLabel = Label(frame, text='Catalog Path')
CatalogEntry = Entry(frame)
Ejemplo n.º 58
0
	def __init__(self, root):
		register_openers()
		Tkinter.Frame.__init__(self, root)
		self.root = root
		self.root.title("GoData Client Module")
		self.grid()
		Style().configure("TButton", padding=(0, 5, 0, 5), 
          	font='serif 10')
        
       		self.root.columnconfigure(0, pad=3)
        	self.root.columnconfigure(1, pad=3)
        	self.root.columnconfigure(2, pad=3)
        	self.root.columnconfigure(3, pad=3)
		self.root.columnconfigure(4, pad=3)
        
       		self.root.rowconfigure(0, pad=3)
        	self.root.rowconfigure(1, pad=3)
        	self.root.rowconfigure(2, pad=3)
        	self.root.rowconfigure(3, pad=3)
        	self.root.rowconfigure(4, pad=3)
		self.root.rowconfigure(5, pad=3)
		self.root.rowconfigure(6, pad=3)
		self.root.rowconfigure(7, pad=3)
		self.root.rowconfigure(8, pad=3)
		self.root.rowconfigure(9, pad=3)
		self.root.rowconfigure(10, pad=3)
		self.root.rowconfigure(11, pad=3)
		self.root.rowconfigure(12, pad=3)
		self.root.rowconfigure(13, pad=3)
		self.root.rowconfigure(14, pad=3)
		self.root.rowconfigure(15, pad=3)
		self.root.rowconfigure(16, pad=3)
		self.root.rowconfigure(17, pad=3)
		self.root.rowconfigure(18, pad=3)
		self.root.rowconfigure(19, pad=3)
		self.root.rowconfigure(20, pad=3)
		self.root.rowconfigure(21, pad=3)
		self.root.rowconfigure(22, pad=3)

		self.root.rowconfigure(0, weight=1)
        	self.root.columnconfigure(0, weight=1)
		global e
		e = Entry(self, width=4)
		e.grid(row=16, column=4)
		e.focus_set()
		
		#self.button = Button(self, text="Upload", fg="red", command=self.logout)
		#self.button.pack(side = RIGHT)
		
		
  		button_opt = {'fill': Tkconstants.BOTH, 'padx': 5, 'pady': 5}
		a = Tkinter.Button(self, text='Browse', command=self.askopenfilename)#.pack(**button_opt)
		a.grid(row =1 , column =4)		
		b = Tkinter.Button(self, text='Upload', command=self.upload)#.pack(**button_opt)
		b.grid(row = 3, column =4)		
		
		f=client.doCmd({"cmd":"view"})
		for i in f:
			FileInfo[i.split(":")[0]].append(i.split(":")[1].split("/")[-1])		
		
		print FileInfo
       		t = SimpleTable(self, len(f)/5,5)
		t.grid(row = 4, column =4)
		
		#MyButton1 = Button(self, text="Download 5", width=14, command=self.Download)
		#MyButton1.grid(row=15, column=4)

		#MyButton2 = Button(self, text="Download 6", width=14, command=self.Download)
		#MyButton2.grid(row=15, column=5)

		#MyButton3 = Button(self, text="Download 7", width=14, command=self.Download)
		#MyButton3.grid(row=15, column=6)	
	
		#MyButton4 = Button(self, text="Download 4", width=14, command=self.Download)
		#MyButton4.grid(row=15, column=3)

		#MyButton5 = Button(self, text="Download 3", width=14, command=self.Download)
		#MyButton5.grid(row=15, column=2)

		#MyButton6 = Button(self, text="Download 2", width=14, command=self.Download)
		#MyButton6.grid(row=15, column=1)

		#MyButton7 = Button(self, text="Download 1", width=14, command=self.Download)
		#MyButton7.grid(row=15, column=0)

		#MyButton8 = Button(self, text="Download 8", width=14, command=self.Download)
		#MyButton8.grid(row=15, column=7)

		MyButton9 = Button(self, text="Download", width=14, command=self.callback)
		MyButton9.grid(row=17, column=4)

		creation = tk.Label( self, text = "Created by Kuber, Digvijay, Anahita & Payal", borderwidth =5, width =45)
		creation.grid(row=50 , column = 4)
		

	
		self.file_opt = options = {}		
  		options['defaultextension'] = '.txt'
  		options['filetypes'] = [('all files', '.*'), ('text files', '.txt')]
  	        options['initialdir'] = 'C:\\'
  		options['initialfile'] = 'myfile.txt'
  	        options['parent'] = root
  	        options['title'] = 'Browse'

		self.dir_opt = options = {}
  		options['initialdir'] = 'C:\\'
  		options['mustexist'] = False
  		options['parent'] = root
  		options['title'] = 'Browse'

		image = Image.open("./header.png")
		photo = ImageTk.PhotoImage(image)
		label = Label(image=photo)
		label.image = photo # keep a reference!
		label.place(width=768, height=576)
		label.grid(row = 0 , column = 0 )
		label.pack(side = TOP)

		self.centerWindow()
		self.master.columnconfigure(10, weight=1)
		#Tkinter.Button(self, text='upload file', command=self.Fname).pack(**button_opt)	
		t = self.file_name = Text(self, width=39, height=1, wrap=WORD)
		t.grid(row = 2, column =4)
		extra1 = tk.Label(self, text = "please give a file number", borderwidth = 5, width =45)
		extra1.grid(row =15, column =4)