def make_entry(self, label, var):
     l = Label(self.top, text=label)
     l.grid(row=self.row, column=0, sticky="ne", padx=6, pady=6)
     e = Entry(self.top, textvariable=var, exportselection=0)
     e.grid(row=self.row, column=1, sticky="nwe", padx=6, pady=6)
     self.row = self.row + 1
     return e
 def new_about_window(self):
     win = tk.AppWindow(self)
     win.withdraw()
     win.title("About Topographica")
     text = Label(win,text=topo.about(display=False),justify=LEFT)
     text.pack(side=LEFT)
     win.deiconify()
Beispiel #3
0
 def __init__(self, _text):
     root = Tk()
     root.title("Steep Hound alert")
     label = Label(root, text=_text)
     label.pack(ipadx=5, ipady=5, padx=5, pady=5)
     root.after(5000, root.destroy)
     root.mainloop()
    def show_setting_window(self, parameters, commands):
        """ Show a parameter setting window.

        parameters: A list of dictionaries {'parameter name': default_value}
        commands: A list of dictionary {'name of button': command}
        """
        self.root = Tk()
        self.root.title('SetParameter')

        frame1 = Frame(self.root, padx=5, pady=5)
        frame1.pack(side='top')

        self.entry = []
        for i, parameter in enumerate(parameters):
            label = Label(frame1, text=parameter.items()[0][0] + ' = ')
            label.grid(row=i, column=0, sticky=E)
            self.entry.append(Entry(frame1, width=10))
            self.entry[i].grid(row=i, column=1)
            self.entry[i].delete(0, END)
            self.entry[i].insert(0, parameter.items()[0][1])
        self.entry[0].focus_set()

        frame2 = Frame(self.root, padx=5, pady=5)
        frame2.pack(side='bottom')

        self.button = []
        for i, command in enumerate(commands):
            self.button.append(Button(frame2, text=command.items()[0][0],
                                      command=command.items()[0][1]))
            self.button[i].grid(row=0, column=i)

        self.root.mainloop()
 def __init__(self, parent, group, **kw):
     self._group = group
     kw['text'] = str(group)
     #        kw.setdefault('anchor', 'w')
     kw.setdefault('font', tkFont.Font(size=20))
     Label.__init__(self, parent, **kw)
     self._init_menu()
class encoderface(LabelFrame):

    def __init__(self, x):
        LabelFrame.__init__(self, x)       
#        self.default_font = tkFont.nametofont("TkDefaultFont")
#        self.default_font.configure(family="Helvetica",size=12)
        self.config(relief=GROOVE)
        self.config(borderwidth=2, padx=5, pady=5)
        self.config(text = "Encoder")
        self.config(labelanchor = "n")

        self.INSTRUCTION = StringVar()
        self.INSTRUCTION.set("Instruction")
        
        self.machinecode = StringVar()
        self.machinecode.set("")

        self.codeEntry = Entry(self, textvariable=self.INSTRUCTION)

        #self.codeEntry.configure(font=("Helvetica", 12), width=40)
        self.codeEntry.configure(width=40)

        self.codeButton = Button(self, text="Compile")

        self.VHPL = Label(self, text="VHPL")

        self.codeButton.grid(row=0, column=0, rowspan=4, sticky="wens")

        self.VHPL.grid(row=0, column=1, sticky="wens")
        self.VHPL.config(relief=GROOVE, borderwidth=2)
        
        self.codeEntry.grid(row=1, column=1, sticky="wens")
        self.codeEntry.config(fg="green", bg="black")
        
        self.pack()
class SplitData:
    def __init__(self):
        root = Tk()
        root.title("split data")
        root.geometry("200x200")
        menu = Menu(root)
        root.config(menu=menu)
        filemenu = Menu(menu)
        menu.add_cascade(label="File", menu=filemenu)
        filemenu.add_command(label="Load data",command = self.load_data)
        self.notifcation = Label(root,text="")
        self.notifcation.grid(row=0,column=0)

        root.mainloop()
        
    def load_data(self):
        # calls the file dialog box
        name = askopenfilename() 
        (d_path,d_name)=split(name)
        fparts = d_name.split('.')
        count=0
        l_file = join(d_path,'run'+str(count)+fparts[0]+'.csv')
        out_f = open(l_file, 'w')
        with open(name) as in_f:
            for line in in_f:
                data = line.split(',')
                if len(data)>1:
                    out_f.write(line)
                else:
                    out_f.close()
                    count+=1
                    l_file = join(d_path,'run'+str(count)+fparts[0]+'.csv')
                    out_f = open(l_file, 'w')
        self.notifcation.config(text="Done")
Beispiel #8
0
    def __init__(self, parent):
        Frame.__init__(self, parent, background=Palette.background)
        self.parent = parent
        self.pack(fill=TkC.BOTH, expand=1)

        # init the clock
        clock_font = tkFont.Font(family='Droid Sans', size=52, weight='bold')
        self.clock = Label(self, text="??:??", fg=Palette.primary, bg=Palette.background, font=clock_font)
        self.clock.place(x=0, y=0)

        # init the calendar
        calendar_font = tkFont.Font(family='Droid Sans', size=12)
        self.calendar = Label(self, text="?? ?????, ???", fg=Palette.secondary, bg=Palette.background, font=calendar_font)
        self.calendar.place(x=4, y=70)

        # init the weather
        self.weather = Weather(self, 320, 82)
        self.weather.place(x=0, y=(240 - 82))

        # init the temperature
        temperature_font = tkFont.Font(family='Droid Sans', size=12)
        self.temperature = Label(self, text="?? °C", fg=Palette.secondary, bg=Palette.background, font=temperature_font)
        self.temperature.place(x=240, y=50)

        # print tkFont.families()
        # ('Century Schoolbook L', 'Droid Sans Mono', 'Droid Sans Ethiopic', 'Droid Sans Thai', 'DejaVu Sans Mono', 'URW Palladio L', 'Droid Arabic Naskh', 'URW Gothic L', 'Dingbats', 'URW Chancery L', 'FreeSerif', 'DejaVu Sans', 'Droid Sans Japanese', 'Droid Sans Georgian', 'Nimbus Sans L', 'Droid Serif', 'Droid Sans Hebrew', 'Droid Sans Fallback', 'Standard Symbols L', 'Nimbus Mono L', 'Nimbus Roman No9 L', 'FreeSans', 'DejaVu Serif', 'Droid Sans Armenian', 'FreeMono', 'URW Bookman L', 'Droid Sans')

        # start working
        self.update_clock()
        self.update_temperature()
        self.fetch_weather_thread()
Beispiel #9
0
class MarcaFoto(Frame):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.grid(column=0, row=0)
        self.canvas = Canvas(self, width=604, height=480)
        self.canvas.grid(column=0, row=0, columnspan=2)
        self.coords = Label(self)
        self.coords.grid(column=0, row=1)
        nome_arq_foto = 'turma1-640x480.gif'
        self.foto = PhotoImage(file=nome_arq_foto)
        self.canvas.create_image(0, 0, image=self.foto, anchor=NW)
        self.canvas.bind('<Motion>', self.moveu)
        self.canvas.bind('<ButtonPress>', self.marcar)
        self.marca_ativa = None
        
    def moveu(self, evento):
        if self.marca_ativa is not None:
            bbox = self.canvas.coords(self.marca_ativa)
            bbox[2:4] = [evento.x, evento.y]
            self.canvas.coords(self.marca_ativa, *bbox)
        
    def marcar(self, evento):
        if self.marca_ativa is None:
            self.marca_ativa = self.canvas.create_oval(evento.x, evento.y, evento.x, evento.y,
                outline='green', width=5)
        else:
            coords = [int(i) for i in self.canvas.coords(self.marca_ativa)]
            self.coords['text'] = coords
            print coords
            self.marca_ativa = None
class RecordController(Frame):
    def __init__(self, master, *args, **kwargs):
        super(RecordController, self).__init__(master, *args, **kwargs)
        self.master = master
        self.current_record = 0
        self.create_widgets()

    def create_widgets(self):
        self.record_label = Label(self, text='Records')
        self.record_label.grid(column=1, row=1)
        self.to_beginning_button = Button(self, text='|<')
        self.to_beginning_button.grid(column=2, row=1)
        self.to_backone_button = Button(self, text='<')
        self.to_backone_button.grid(column=3, row=1)

        self.search_field = Entry(self)
        self.search_field.grid(column=4, row=1)

        self.to_fowardone_button = Button(self, text='>')
        self.to_fowardone_button.grid(column=5, row=1)
        self.to_end_button = Button(self, text='>|')
        self.to_end_button.grid(column=6, row=1)

    def on_get_record_button_press(self, event):
        if event.widget.text == '|<':
            self.current_record = 0
        elif event.widget.text == '<':
            self.current_record -= 1
            if self.current_record < 0:
                self.current_record = 0
        elif event.widget.text == '>':
            self.current_record += 1
        elif event.widget.text == '>|':
            self.current_record += 1  # TODO This isnt right for now
Beispiel #11
0
 def initBoard(self):
     self.brd=Image.open("imgs/blank_board.jpg")
     tatras=ImageTk.PhotoImage(self.brd,height=self.parent.winfo_screenheight())
     label=Label(self,image=tatras)
     label.image=tatras
     label.pack()
     self.pack()
Beispiel #12
0
    def initialize(self):
        self.grid()
        self.entryVariable = StringVar()
        self.entry = Entry(self, textvariable=self.entryVariable)
        self.entry.grid(column=0,row=0,sticky='EW')
        self.entry.bind("<Return>", self.OnPressEnter)

        button = Button(self,text="SPI send", command=self.OnButtonClick)
        button.grid(column=1,row=0)
        
        #ramp = Button(self,text="RAMP", command=self.setlabvar)
        #ramp.grid(column=1,row=1)        

        self.labelVariable = StringVar()
        label = Label(self,textvariable=self.labelVariable,
                              anchor="w",fg="white",bg="blue")
        label.grid(column=0,row=1,columnspan=1,sticky='EW')
        self.labelVariable.set("Start..")
        
        self.slider = Scale(self, from_=0, to=80, orient=HORIZONTAL, 
                            command=self.setlabvar)
        self.slider.grid(column=0, row=2, columnspan=3, sticky='EW')
        
        self.PID = PIDTune(self)
        self.PID.grid(column=0, row=3, columnspan=3, sticky='EW')
        
        self.grid_columnconfigure(0,weight=1)
        self.update()
        #self.geometry(self.geometry()) # caused busy wait?
        self.entry.focus_set()
Beispiel #13
0
class Status(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.create_widget()

    def create_widget(self):
        self.create_message_button()
        self.create_apply_button()
        self.create_people_button()
        self.create_status_text()
        self.pack_all()

    def create_message_button(self):
        self.message_button = Button(self, text='消息中心')
        self.message_button['command'] = None

    def create_apply_button(self):
        self.apply_button = Button(self, text='放款申请')
        self.apply_button['command'] = None
        
    def create_people_button(self):
        self.people_button= Button(self, text='客户信息')
        self.people_button['command'] = None
        
    def create_status_text(self):
        self.status_text_label = Label(self, text='当前用户> 当前>', width=80)
        self.status_text_label['anchor'] = 'e'

    def pack_all(self):
        self.message_button.pack(side=Tkinter.LEFT)
        self.apply_button.pack(side=Tkinter.LEFT)
        self.people_button.pack(side=Tkinter.LEFT)
        self.status_text_label.pack()
Beispiel #14
0
    def directions_window():
        directions_window = Tk()
        directions_window.title("How To Operate The Board")

        label = Label(directions_window, text="Left Click to pick a piece \n Right Click to place the piece", height=20,
                      width=50)
        label.pack()
Beispiel #15
0
    def _setImage(self, imageName):
        """Display the image of this frame
        
        Argument
        imageName -- the name of the image
        
        """
        imageNameFull = os.path.join(self._wdir, imageName)
        
        try:
            image = Image.open(imageNameFull)
        except IOError:
            return

        image.thumbnail((_previewWidth, _previewHeight), Image.ANTIALIAS)
        imageTk = ImageTk.PhotoImage(image)

        self._lblImagenamefull.set(imageName)
        self._setLabel(self._lblImagename, imageName)
        
        
        if(self._il != None):
            self._il.destroy()

        #Show image
        imagelabel = Label(self._imageFrame, image = imageTk)
        imagelabel.place(relx=.5, rely=.5, anchor="c")   
        self._il = imagelabel 
        self._imageRef = imageTk
Beispiel #16
0
class ClsFrmKeyValue(Frame):
    """
    Класс обеспечивает работу с парой ключ:значение.
    """
    def __init__(self, root=None, key='Key', value='None'):
        """
        Конструтирует пару ключ:значение.
        :param root:
        :param key:
        :param value:
        :return:
        """
        self.__root = root
        Frame.__init__(self, master=root, border=2, relief='ridge')
        self.pack(fill='x', side='top')

        self.lbl_key = Label(self, text=key, border=1, relief='ridge', width=14)
        self.lbl_key.pack(side='left', fill='x', expand=1)

        self.ent_val = Entry(self, border=1, relief='groove')
        self.ent_val.pack(side='left', fill='x', expand=1)
        self.ent_val.delete(0, 'end')
        self.ent_val.insert(0, value)

    def get_val(self):
        """
        Возвращает значение ключа из пары ключ:значение.
        :return:
        """
        return self.ent_val.get()
    def createCanvas( self ):
        "Create and return our scrolling canvas frame."
        f = Frame( self )

        canvas = Canvas( f, width=self.cwidth, height=self.cheight,
                         bg=self.bg )

        # Scroll bars
        xbar = Scrollbar( f, orient='horizontal', command=canvas.xview )
        ybar = Scrollbar( f, orient='vertical', command=canvas.yview )
        canvas.configure( xscrollcommand=xbar.set, yscrollcommand=ybar.set )

        # Resize box
        resize = Label( f, bg='white' )

        # Layout
        canvas.grid( row=0, column=1, sticky='nsew')
        ybar.grid( row=0, column=2, sticky='ns')
        xbar.grid( row=1, column=1, sticky='ew' )
        resize.grid( row=1, column=2, sticky='nsew' )

        # Resize behavior
        f.rowconfigure( 0, weight=1 )
        f.columnconfigure( 1, weight=1 )
        f.grid( row=0, column=0, sticky='nsew' )
        f.bind( '<Configure>', lambda event: self.updateScrollRegion() )

        # Mouse bindings
        canvas.bind( '<ButtonPress-1>', self.clickCanvas )
        canvas.bind( '<B1-Motion>', self.dragCanvas )
        canvas.bind( '<ButtonRelease-1>', self.releaseCanvas )

        return f, canvas
Beispiel #18
0
    def __init__(self, image):
        self.original = image
        self.image = image.copy()
        self.window = Tk()

        self.genViews()
        self.currentView = StringVar(self.window)
        self.currentView.set('Original')
        options = self.filters.keys();options.sort()
        self.views = OptionMenu(self.window, self.currentView,
                *options, command=self.applyFilter)
        self.views.pack()

        self.tkImage = ImageTk.PhotoImage(image)
        self.lblImage = Label(image=self.tkImage)
        self.lblImage.bind('<Button-1>', self.displayInfos)
        self.lblImage.bind('<Button-3>', self.save)
        self.lblImage.image = self.tkImage
        self.lblImage.pack()

        self.status = StringVar()
        self.lblStatus = Label(textvariable=self.status, justify='right')
        self.lblStatus.pack()

        self.window.mainloop()
Beispiel #19
0
	def show(self):
		self.root.withdraw()
		if self.flag:
			img_file = os.path.join(app.config.sk_share_dir, self.img + '.png')
			from sk1sdk.tkpng import load_icon
			load_icon(self.root, img_file, self.img)

			scrnWt = self.root.winfo_screenwidth()
			scrnHt = self.root.winfo_screenheight()
			winXPos = (scrnWt / 2) - (self.width / 2)
			winYPos = (scrnHt / 2) - (self.height / 2)

			self.win = Toplevel()
			self.win.overrideredirect(1)
			self.win.configure(background='black')
			self.banner = Label(self.win, image=self.img, cursor='watch',
							borderwidth=0)
			self.banner.pack()

			self.verlb = Label(self.win, text='version %s' % (config.version,),
							bg='white')
			self.verlb.place(x=10, y=240)
			self.verlb['font'] += ' bold'

			self.txtlb = Label(self.win, text='Start...',
							bg='white')
			self.txtlb.place(x=10, y=265)
			self.progress_bar = SS_ProgressBar(self.win)
			self.progress_bar.pack(fill=X, side=TOP)
			geom = (self.width, self.height, winXPos, winYPos)
			self.win.geometry('%dx%d+%d+%d' % geom)
			self.win.update()
class WaitingUI(Frame):
    def __init__(self,parent,filePath):
        Frame.__init__(self,parent)
        self.parent = parent
        self.names = None
        self.filePath = filePath
        self.initUI()
        self.centerWindow()
        self.readFile()
    
    def onReadFinish(self):
        self.parent.destroy()
        chooseName(self.names)
    
    def readFile(self):
        t = conversationtool.readThread(self,self.filePath)
        t.start()
        t.join()
        self.onReadFinish()
        
    def initUI(self):
        self.parent.title("请等待。。。")
        self.pack(fill=BOTH, expand=1)
        self.label = Label(self, text="请等待...")        
        self.label.place(x=60, y=80)
        
    def centerWindow(self):
        w = 300
        h = 150
        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()
        x = (sw - w)/2
        y = (sh - h)/2
        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
Beispiel #21
0
class StarterWindow(Tk):
    def __init__(self):
        Tk.__init__(self)
        self.wm_title("FRCA QBase Reader - Start Menu")
        self.exambtn = Button(self, text="start an exam", command=self.startExam)
        self.exambtn.pack()
        self.maxquestvar = IntVar()
        self.maxquest = Spinbox(self, from_=1, to=1667, width=4, textvariable=self.maxquestvar)
        self.maxquest.pack()
        self.questbtn = Button(self, text="start single questions", command=self.startQuestions)
        self.questbtn.pack()
        self.um = """User manual:\n
		Start either an exam or single questions\n
		Go to next question either with mouse or the <right arrow>\n
		Toggle checkboxes either with mouse or <keyboard buttons 1-5>\n
		In single question mode, show answer either with mouse or <return>\n
		In exam mode, results will display after the set question number\n
		Text can be made bigger/smaller with <Up> or <Down> keyboard arrows"""
        self.usermanual = Label(self, text=self.um, justify=LEFT)
        self.usermanual.pack()

    def startExam(self):
        call(["python", "exam.py", str(self.maxquestvar.get())])

    def startQuestions(self):
        call(["python", "quest_by_quest.py"])
class CaptionedImage:
  def __init__(self, root, width, height, left, top):
    self.root = root
    self.dimensions = (width,height)
    self.position = (left,top)
    self.image_label = None
  def set_image(self, image):
    # Fit image to width.
    width = self.dimensions[0]
    image = image.resize( (width,width) )
    # Put the image on a Tk label.
    tkpi = ImageTk.PhotoImage(image)
    image_label = Label(root, image=tkpi)
    # Don't let the image get collected prematurely (from tkinterbook.)
    image_label.tkpi = tkpi
    image_label.place(x=self.position[0], y=self.position[1])
    # See if we have one we need to destroy
    if self.image_label:
      self.image_label.destroy()
    self.image_label = image_label
  def set_caption(self, text):
    # Make another label for the caption.
    self.caption_label = Label(root, text=text)
    left = self.position[0]  # We use the same width as the image, then center.
    width = self.dimensions[0]
    top = self.position[1] + self.dimensions[1] # Set it below the image.
    self.caption_label.place(x=left, y=top, width=width)
Beispiel #23
0
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller
        self._board = TicTacToe(4)
        self.startplayer = self._board.X_VAL
        self.currentPlayer = self.startplayer
        self.buttons = {}


        # status = lambda: self.get_status()
        label = Label(self, text="Tic Tac Toe", font=TITLE_FONT)
        label.grid(row=0, column=0, columnspan=4)
        self.status = Label(self, text='Your Turn')
        self.status.grid(row=1, column=0, columnspan=self._board.size, sticky="WE")
        for x in range(self._board.size):
            for y in range(self._board.size):
                handler = lambda x=x,y=y: self.move(x,y)
                button = Button(self, command=handler, font=X_O_FONT, width=3, height=1)
                button.grid(row=x+2, column=y)
                self.buttons[x,y] = button
        handler = lambda: self.reset()
        button = Button(self, text='Reset', command=handler)
        button.grid(row=self._board.size+3, column=2, columnspan=2, sticky="WE")
        button = Button(self, text="Go to the start page",
                           command=lambda: self.start_and_reset())
        button.grid(row=self._board.size+3, column=0, columnspan=2, sticky="WE")
        self.update()
Beispiel #24
0
    def get_name(self):
        frame = DraggableFrame(self._root)
        frame.pack(side=TOP, fill=BOTH, expand=YES)

        frame.columnconfigure(0, weight=1)
        frame.columnconfigure(4, weight=1)
        frame.rowconfigure(0, weight=1)
        frame.rowconfigure(4, weight=1)

        w = self._set_frame_geo(frame, 0.3, 0.3)[2]
        self._set_x_button(frame, w, self._close_get_name)
        Label(frame, text="Name:").grid(column=1, row=1)
        entry_style = SUNKEN if self._is_osx else FLAT
        entry = Entry(frame, exportselection=0, relief=entry_style, textvariable=self._name)
        entry.grid(column=2, row=1)
        entry.focus_set()
        error_label = Label(frame, fg='red')
        error_label.grid(column=1, row=2, columnspan=3)

        ok_cmd = partial(self._validate_name, error_label)
        FlatButton(frame, text='OK', width=20, font=("calibri", 15),
                   command=ok_cmd).grid(column=1, row=3, columnspan=3)

        self._root.bind('<Return>', ok_cmd)
        self._root.bind('<Escape>', self._close_get_name)
        self._run()
        return self._name.get() if self._name else self._name
Beispiel #25
0
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller
        self.size = None
        self.first_player = None
        self._board = TicTacToe(3)
        self.new_ai = AI('O', self._board)
        self.buttons = {}

        label = Label(self, text="Tic Tac Toe", font=TITLE_FONT)
        label.grid(row=0, column=0, columnspan=3)
        self.status = Label(self, text='Your Turn')
        self.status.grid(row=1, column=0, columnspan=3)
        for x in range(self._board.size):
            for y in range(self._board.size):
                handler = lambda x=x,y=y: self.move(x,y)
                button = Button(self, command=handler, font=X_O_FONT, width=5, height=2)
                button.grid(row=x+2, column=y)
                self.buttons[x,y] = button
        handler = lambda: self.reset()
        button = Button(self, text='Reset', command=handler)
        button.grid(row=self._board.size+3, column=2,  sticky="WE")
        button = Button(self, text="Go to the start page",
                        command=lambda: self.start_and_reset())
        button.grid(row=self._board.size+3, column=0, columnspan=2, sticky="WE")
        self.update()
Beispiel #26
0
 def redraw(self):
     # Even though there are never more than three widgets per row,
     # we have four columns, to allow the taskname label and the
     # input widget to stretch.
     self.grid_columnconfigure(2, weight=1)
     row = 0
     # Add a new row of widgets for each task.
     for rec in sorted(self.table.query(), key=lambda rec: rec.get('created')):
         # Extract the fields we need.
         completed = rec.get('completed')
         taskname = rec.get('taskname')
         # Create a button with an 'X' in it, to delete the task.
         close_btn = Button(self, text='X',
                            command=lambda rec=rec: self.delete_rec(rec))
         close_btn.grid(row=row, column=0)
         # Create a checkbox, to mark it completed (or not).
         var = BooleanVar(self, value=completed)
         completed_btn = Checkbutton(self, variable=var,
                                     command=lambda rec=rec, var=var:
                                             self.toggle_rec(rec, var))
         completed_btn.grid(row=row, column=1)
         # Create a label showing the task name.
         taskname_lbl = Label(self, text=taskname, anchor=W)
         taskname_lbl.grid(row=row, column=2, columnspan=2, sticky=W)
         row += 1  # Bump row index.
     # Add a final row with the input and button to add new tasks.
     self.input = Entry(self)
     self.input.bind('<Return>', self.add_rec)
     self.input.grid(row=row, column=0, columnspan=3, sticky=W+E)
     add_btn = Button(self, text='Add Task', command=self.add_rec)
     add_btn.grid(row=row, column=3)
     # Add save button.  (Auto-save is left as an exercise.)
     save_btn = Button(self, text='Save local snapshot', command=self.save)
     save_btn.grid(row=row+1, column=0, columnspan=3, sticky=W)
Beispiel #27
0
	def zobrazVysledek(self):
		profil.odkaz_Hledany = self.vstupniPole.get()
		profil.ziskejObsah()
		profil.ziskejJmeno()
		
		pritel.vyhledejIdentifikator()
		
		self.vysledek = Label(self, text = "Searched Steam profile: %s\nNickname:\t%s" % (pritel.celkovyPocet,profil.prezdivka_Hledany))
		self.vysledek.grid(row = 1, column = 0, columnspan = 2, sticky = W)
		self.vysledek = Label(self, text = "========================================")
		self.vysledek.grid(row = 2, column = 0, columnspan = 2, sticky = W)
		
		for klic, hodnota in sorted(pritel.seznamBuddy.items()):
			
			self.pocitadloRadky = self.pocitadloRadky + 1
			self.vysledek = Label(self, text = "%s\t%s" % (klic, hodnota))
			self.vysledek.grid(row = self.pocitadloRadky + 1, column = self.pocitadloSloupce, columnspan = 1, sticky = W)
			
			if self.pocitadloRadky % 36 == 0:
				self.pocitadloRadky = 2
				self.pocitadloSloupce = self.pocitadloSloupce + 1
		
		#self.vysledek = Label(self, text = "%s" % (self.vstupniPole.get())) - this is a reference, dont delete it.
		#self.vysledek.grid(row = 1, column = 0, columnspan = 2, sticky = W)
		
		self.Tlacitko = Button(self, text = "Save to file", command = pritel.ulozSoubor())
		self.Tlacitko.grid(row = 0, column = 4, ipadx = 20)
class ParamItem(Frame):
    
    def __init__(self, master, itemList, deleteCount):
        Frame.__init__(self, master)
        self.labelKey = Label(self, text = "Key:")
        self.labelValue = Label(self, text = "Value:")
        self.entryKey = Entry(self, width = 8)
        self.entryValue = Entry(self, width = 20)
        self.deleteCount = deleteCount
        self.itemList = itemList
        self.btnDelete = Button(self, text = "delete", \
            command = self.__internalDelete, padx = 5)
        self.__boxComponents()
    
    def __boxComponents(self):
        self.labelKey.grid(row = 0, column = 0)
        self.entryKey.grid(row = 0, column = 1)
        self.labelValue.grid(row = 0, column = 2)
        self.entryValue.grid(row = 0, column = 3)
        self.btnDelete.grid(row = 0, column = 4)
    
    def __internalDelete(self):
        self.deleteCount.set(self.deleteCount.get() + 1)
        self.itemList.remove(self)
        self.destroy()
    def getKey(self):
        return self.entryKey.get()
    
    def getValue(self):
        return self.entryValue.get()
class MyFirstGUI:
    LABEL_TEXT = [
        "This is our first GUI!",
        "Actually, this is our second GUI.",
        "We made it more interesting...",
        "...by making this label interactive.",
        "Go on, click on it again.",
    ]

    def __init__(self, master):
        self.master = master
        master.title("A simple GUI")

        self.label_index = 0
        self.label_text = StringVar()
        self.label_text.set(self.LABEL_TEXT[self.label_index])
        self.label = Label(master, textvariable=self.label_text)
        self.label.bind("<Button-1>", self.cycle_label_text)
        self.label.pack()

        self.greet_button = Button(master, text="Greet", command=self.greet)
        self.greet_button.pack()

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()

    def greet(self):
        print("Greetings!")

    def cycle_label_text(self, event):
        self.label_index += 1
        self.label_index %= len(self.LABEL_TEXT)  # wrap around
        self.label_text.set(self.LABEL_TEXT[self.label_index])
Beispiel #30
0
    def displayAndUpdate(self):
        self.output_img_tmp = Image.fromarray(self.output_img)
        self.output_img_tk = ImageTk.PhotoImage(image=self.output_img_tmp)

        self.input_img_tmp = Image.fromarray(self.input_img)
        self.input_img_tk = ImageTk.PhotoImage(image=self.input_img_tmp)

        if self.input_img_tk.width() < 500:
            self.parent.geometry("%dx%d+%d+%d" % (self.input_img_tk.width()*2, self.input_img_tk.height()+50, 100, 100) )
        else:
            self.input_img_tmp = self.input_img_tmp.resize((500, self.input_img_tk.height() * 500 / self.input_img_tk.width()),Image.ANTIALIAS)
            self.input_img_tk = ImageTk.PhotoImage(image=self.input_img_tmp)
            self.output_img_tmp = self.output_img_tmp.resize((500, self.output_img_tk.height() * 500 / self.output_img_tk.width()),Image.ANTIALIAS)
            self.output_img_tk = ImageTk.PhotoImage(image=self.output_img_tmp)

            self.parent.geometry("%dx%d+%d+%d" % (1050, self.input_img_tk.height() + 50, 100, 100) )
        
        self.input_img_label = Label(self.parent, image=self.input_img_tk, borderwidth=3, height=self.input_img_tk.height(), width=self.input_img_tk.width())
        self.input_img_label.grid(row=0,column=0)

        self.input_img_label_text = Label(self.parent, text="Input Image")
        self.input_img_label_text.grid(row=1,column=0)

        self.output_img_label = Label(self.parent, image=self.output_img_tk, borderwidth=3, height=self.output_img_tk.height(), width=self.output_img_tk.width())
        self.output_img_label.grid(row=0,column=1)

        self.output_img_label_text = Label(self.parent, text="Output Image")
        self.output_img_label_text.grid(row=1,column=1)

        self.parent.update()
Beispiel #31
0
from Tkinter import Tk, Label, Button
root = Tk()
root.option_readfile('hello.txt')
labelHello = Label(root, text="Hello World !")
labelBonjour = Label(root, name="labelBonjour")
labelHello.pack()
labelBonjour.pack()
buttonQuit = Button(root, text="Goodbye World", fg="red", command=root.destroy)
buttonQuit.pack()
root.mainloop()
exit(0)
Beispiel #32
0
    def __init__(self, master):
        self.master = master
        master.title("GeoGUI")
        self.w = "X Min:"
        self.inputw = 0
        self.e = "X Max:"
        self.inpute = 0
        self.s = "Y Min:"
        self.inputs = 0
        self.n = "Y Max:"
        self.inputn = 0

        self.w_label_text = StringVar()
        self.w_label = Label(master, textvariable=self.w_label_text)
        self.w_label_text.set(self.w)
        self.e_label_text = StringVar()
        self.e_label = Label(master, textvariable=self.e_label_text)
        self.e_label_text.set(self.e)
        self.n_label_text = StringVar()
        self.n_label = Label(master, textvariable=self.n_label_text)
        self.n_label_text.set(self.n)
        self.s_label_text = StringVar()
        self.s_label = Label(master, textvariable=self.s_label_text)
        self.s_label_text.set(self.s)

        self.label = Label(master, text="X min:")
        self.label = Label(master, text="X max:")
        self.label = Label(master, text="Y min:")
        self.label = Label(master, text="Y max:")

        wvcmd = master.register(self.wvalidate)
        evcmd = master.register(self.evalidate)
        svcmd = master.register(self.svalidate)
        nvcmd = master.register(self.nvalidate)

        # we have to wrap the command
        self.entryw = Entry(master,
                            validate="key",
                            validatecommand=(wvcmd, '%s'))
        self.entrye = Entry(master,
                            validate="key",
                            validatecommand=(evcmd, '%s'))
        self.entrys = Entry(master,
                            validate="key",
                            validatecommand=(svcmd, '%s'))
        self.entryn = Entry(master,
                            validate="key",
                            validatecommand=(nvcmd, '%s'))

        self.w_label.pack()
        self.entryw.pack()
        self.e_label.pack()
        self.entrye.pack()
        self.s_label.pack()
        self.entrys.pack()
        self.n_label.pack()
        self.entryn.pack()

        self.run_button = Button(master, text="Run", command=self.run)
        self.run_button.pack()

        self.close_button = Button(master, text="Close", command=master.quit)
        self.close_button.pack()
Beispiel #33
0
def error_and_exit(title, main_text):
    """
    Show a pop-up window and sys.exit() out of Python.

    :param title: the short error description
    :param main_text: the long error description
    """
    # NOTE: We don't want to load all of these imports normally.
    #       Otherwise we will have these unused GUI modules loaded in the main process.
    from Tkinter import Tk, Canvas, DISABLED, INSERT, Label, Text, WORD

    root = Tk()
    root.wm_title("Tribler: Critical Error!")
    root.wm_minsize(500, 300)
    root.wm_maxsize(500, 300)
    root.configure(background='#535252')

    # Place the window at the center
    root.update_idletasks()
    w = root.winfo_screenwidth()
    h = root.winfo_screenheight()
    size = tuple(int(_) for _ in root.geometry().split('+')[0].split('x'))
    x = w / 2 - 250
    y = h / 2 - 150
    root.geometry("%dx%d+%d+%d" % (size + (x, y)))

    Canvas(root,
           width=500,
           height=50,
           bd=0,
           highlightthickness=0,
           relief='ridge',
           background='#535252').pack()
    pane = Canvas(root,
                  width=400,
                  height=200,
                  bd=0,
                  highlightthickness=0,
                  relief='ridge',
                  background='#333333')
    Canvas(pane,
           width=400,
           height=20,
           bd=0,
           highlightthickness=0,
           relief='ridge',
           background='#333333').pack()
    Label(pane,
          text=title,
          width=40,
          background='#333333',
          foreground='#fcffff',
          font=("Helvetica", 11)).pack()
    Canvas(pane,
           width=400,
           height=20,
           bd=0,
           highlightthickness=0,
           relief='ridge',
           background='#333333').pack()

    main_text_label = Text(pane,
                           width=45,
                           height=6,
                           bd=0,
                           highlightthickness=0,
                           relief='ridge',
                           background='#333333',
                           foreground='#b5b5b5',
                           font=("Helvetica", 11),
                           wrap=WORD)
    main_text_label.tag_configure("center", justify='center')
    main_text_label.insert(INSERT, main_text)
    main_text_label.tag_add("center", "1.0", "end")
    main_text_label.config(state=DISABLED)
    main_text_label.pack()

    pane.pack()

    root.mainloop()

    # Exit the program
    sys.exit(1)
Beispiel #34
0
    def __init__(self, master):
        self.master = master
        column0_padx = 24
        row_pady = 40
        self.imgck = IntVar()
        self.latck = IntVar()
        self.lonck = IntVar()
        self.timeck = IntVar()
        self.dateck = IntVar()
        self.datestate = int()
        self.imgval = StringVar()
        self.latval = StringVar()
        self.lonval = StringVar()
        self.timeval = StringVar()
        self.dateval = StringVar()
        self.headerVal = IntVar()
        self.rbv = IntVar()
        vcmd = (master.register(self.validate), '%d', '%i', '%P', '%s', '%S',
                '%v', '%V', '%W')

        self.entryExif = Entry(master, relief="sunken")
        self.entryExif.insert(0, "EXIF csv file")
        self.entryExif.grid(row=0, columnspan=4, sticky='EW', padx=5, pady=10)
        exifbtn = Button(master,
                         text="OPEN CSV file",
                         command=self.getEXIFfile)
        exifbtn.grid(row=1, column=0, padx=5, sticky='w')

        ##added to allow header line
        self.headerOpt = Checkbutton(master,
                                     text="Select if CSV file has header line",
                                     variable=self.headerVal)
        self.headerOpt.grid(row=2, column=0, padx=5, sticky='w')

        self.entryJPGS = Entry(master, relief="sunken")
        self.entryJPGS.insert(0, "JPEG folder")
        self.entryJPGS.grid(row=3, columnspan=4, sticky='EW', padx=5, pady=10)
        JPGbtn = Button(master,
                        text="OPEN JPEG folder",
                        command=self.getJPEGFolder)
        JPGbtn.grid(row=4, column=0, padx=5, sticky='w')

        self.paramFile = Entry(master, relief="sunken")
        self.paramFile.insert(0, "Param file")
        self.paramFile.grid(row=5, columnspan=4, sticky='EW', padx=5, pady=10)
        parambtn = Button(master,
                          text="OPEN PARAM file",
                          command=self.getParamfile)
        parambtn.grid(row=6, column=0, padx=5, sticky='w')

        lbl_exiftag = Label(master,
                            text="EXIF tag",
                            wraplength=100,
                            anchor='w',
                            justify='left')
        lbl_column = Label(master,
                           text="CSV column (zero based)",
                           wraplength=100,
                           anchor='w',
                           justify='left')
        cbImage = Checkbutton(master,
                              text='Image name',
                              variable=self.imgck,
                              command=self.imgcheck)
        cbLatitude = Checkbutton(master,
                                 text='Latitude',
                                 variable=self.latck,
                                 command=self.latcheck)
        cbLongitude = Checkbutton(master,
                                  text='Longitude',
                                  variable=self.lonck,
                                  command=self.loncheck)
        cbTime = Checkbutton(master,
                             text='GPSTime',
                             variable=self.timeck,
                             command=self.timecheck)
        cbDate = Checkbutton(master,
                             text='GPSDate',
                             variable=self.dateck,
                             command=self.datecheck)
        lblText = Label(master, text="Free text fields:")
        lblArtist = Label(master, text="Artist:")

        ##        lbl_analysis = Label(master, text="Analysis Library")
        self.entryImage = Entry(master,
                                validate='key',
                                validatecommand=vcmd,
                                width=5,
                                state='disabled')
        self.entryLat = Entry(master,
                              validate='key',
                              validatecommand=vcmd,
                              width=5,
                              state='disabled')
        self.entryLon = Entry(master,
                              validate='key',
                              validatecommand=vcmd,
                              width=5,
                              state='disabled')
        self.entryTime = Entry(master,
                               validate='key',
                               validatecommand=vcmd,
                               width=5,
                               state='disabled')
        self.entryDate = Entry(master,
                               validate='key',
                               validatecommand=vcmd,
                               width=5,
                               state='disabled')
        self.entryArtist = Entry(master, width=40)

        #lbl_testcase_exec.grid(row=0, column=2, padx=20, pady=12, sticky='w')
        lbl_exiftag.grid(row=7, column=0, padx=20, pady=12, sticky='w')
        lbl_column.grid(row=7, column=1, padx=10, pady=12, sticky='w')
        cbImage.grid(row=8, column=0, padx=20, sticky='w')
        cbLatitude.grid(row=9, column=0, padx=20, sticky='w')
        cbLongitude.grid(row=10, column=0, padx=20, sticky='w')
        cbTime.grid(row=11, column=0, padx=20, sticky='w')
        cbDate.grid(row=12, column=0, padx=20, sticky='w')
        lblText.grid(row=13, column=0, padx=30, sticky='w')
        lblArtist.grid(row=14, column=0, padx=20, sticky='w')
        self.entryImage.grid(row=8, column=1, padx=10, sticky='w')
        self.entryLat.grid(row=9, column=1, padx=10, sticky='w')
        self.entryLon.grid(row=10, column=1, padx=10, sticky='w')
        self.entryTime.grid(row=11, column=1, padx=10, sticky='w')
        self.entryDate.grid(row=12, column=1, padx=10, sticky='w')
        lbl_datefmt = Label(master,
                            text="Select date format:",
                            wraplength=500,
                            anchor='w',
                            justify='left')
        lbl_datefmt.grid(row=12, column=1, padx=50, sticky='w')
        self.entryArtist.grid(row=14, column=1, padx=10, sticky='w')
        ##        ##added to allow header line
        ##        self.dateOpt1 = Checkbutton(master, text="YYYYMMDD", variable=self.headerVal)
        ##        self.dateOpt1.grid(row=10, column=1, padx=160, sticky='w')
        ##        self.dateOpt2 = Checkbutton(master, text="YYYY:MM:DD", variable=self.headerVal)
        ##        self.dateOpt2.grid(row=10, column=1, padx=260, sticky='w')
        ##        self.dateOpt3 = Checkbutton(master, text="MM/DD/YYYY", variable=self.headerVal)
        ##        self.dateOpt3.grid(row=10, column=1, padx=360, sticky='w')

        #try radio buttons
        Radiobutton(master,
                    text="YYYYMMDD",
                    variable=self.rbv,
                    value=1,
                    command=self.rdioInvoke).grid(row=10,
                                                  column=1,
                                                  padx=190,
                                                  sticky='w')
        Radiobutton(master,
                    text="YYYY:MM:DD",
                    variable=self.rbv,
                    value=2,
                    command=self.rdioInvoke).grid(row=11,
                                                  column=1,
                                                  padx=190,
                                                  sticky='w')
        Radiobutton(master,
                    text="MM/DD/YYYY",
                    variable=self.rbv,
                    value=3,
                    command=self.rdioInvoke).grid(row=12,
                                                  column=1,
                                                  padx=190,
                                                  sticky='w')
        Radiobutton(master,
                    text="MM/DD/YY",
                    variable=self.rbv,
                    value=4,
                    command=self.rdioInvoke).grid(row=13,
                                                  column=1,
                                                  padx=190,
                                                  sticky='w')

        # buttons
        bottom_frame = Frame(master)
        bottom_frame.grid(row=30, column=1, columnspan=3, sticky='w')

        #I had to add the self to the prefix, otherwise my rdioInvoke wouldn't work.
        #I'm guessing the self is sort of the global aspect.
        #temporarily commenting this out so I can just test reading the param file
        self.btn_start = Button(bottom_frame,
                                text="Submit",
                                width=7,
                                command=self.MergeExif)
        #self.btn_start = Button(bottom_frame, text = "Submit", width=7, command=self.readParamfile)
        self.btn_start.pack(side='left', pady=20)
        self.btn_start.config(state='disabled')
        ##        btn_commit = Button(bottom_frame, text="Commit", width=7)
        ##        btn_commit.pack(side='left', padx=80)
        btn_exit = Button(bottom_frame,
                          text="Exit",
                          width=7,
                          command=self.cbtnClick)
        btn_exit.pack(side='left', padx=10)
Beispiel #35
0
class MainWindow(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        self.parent = parent
        menubar = MenuBar(self)
        self.area = self.create_area()
        self.button_start, self.scale_circle = self.create_controls()
        self.libelle = Label(text="Serious Game",
                             font="Helvetica 14 bold",
                             bg="white",
                             fg="red")
        menubar.pack()
        self.area.pack()
        self.libelle.pack(pady=3)

        self.x, self.y = 100, 100
        self.circle_bb = 100
        self.circle = None
        self.animation_id = None

    def create_area(self):
        canvas = ScrolledCanvas(self,
                                relief="solid",
                                scrollregion=(-600, -600, 600, 600),
                                bd=3)
        return canvas

    def create_controls(self):
        canvas = self.area.get_canvas()
        start = Button(self, text="Start", command=self.start)
        scale = Scale(self,
                      length=250,
                      orient="horizontal",
                      label='Rayon :',
                      troughcolor='dark grey',
                      sliderlength=20,
                      showvalue=0,
                      from_=0,
                      to=100,
                      tickinterval=25,
                      command=self.update_circle)
        scale.set(50)
        canvas.create_window(50, 200, window=start)
        canvas.create_window(250, 200, window=scale)
        return start, scale

    def create_circle(self):
        canvas = self.area.get_canvas()
        if self.circle != None:
            canvas.delete(self.circle)
        self.circle = canvas.create_oval(self.x,
                                         self.y,
                                         self.x + self.circle_bb,
                                         self.y + self.circle_bb,
                                         fill='yellow',
                                         outline='black')
        return self.circle

    def delete_circle(self):
        if self.circle != None:
            canvas = self.area.get_canvas()
            canvas.delete(self.circle)

    def update_circle(self, size):
        canvas = self.area.get_canvas()
        canvas.delete(self.circle)
        self.circle_bb = 2 * int(size)
        self.circle = self.create_circle()

    def animation(self):
        self.x += randrange(-60, 61)
        self.y += randrange(-60, 61)
        canvas = self.area.get_canvas()
        canvas.coords(self.circle, self.x, self.y, self.x + self.circle_bb,
                      self.y + self.circle_bb)
        self.libelle.config(text='Cherchez en %s %s' % (self.x, self.y))
        self.animation_id = self.after(250, self.animation)

    def stop(self):
        self.after_cancel(self.animation_id)
        self.button_start.configure(text="Start", command=self.start)

    def start(self):
        self.button_start.configure(text="Stop", command=self.stop)
        self.animation()

    def stop(self):
        self.parent.destroy()
Beispiel #36
0
class Calculator:
    def __init__(self, master):

        self.master = master
        master.title("Naive Bayes Classifier")
        master.geometry("450x300")

        self.directory_path_text = Entry(master)
        self.directory_path_label = Label(master, text="Directory Path")

        def open_dialog():
            directoryPath = askdirectory()
            self.directory_path_text.delete(0, END)
            self.directory_path_text.insert(0, directoryPath)

        self.bins_label = Label(master, text="Discretization Bins")
        vcmd = master.register(self.validate)  # we have to wrap the command
        self.entry = Entry(master,
                           validate="key",
                           validatecommand=(vcmd, '%P'))

        self.browse_button = Button(master, text="Browse", command=open_dialog)

        self.build_button = Button(master,
                                   text="Build",
                                   command=lambda: self.checkValidate())
        self.classify_button = Button(master,
                                      text="Classify",
                                      command=lambda: self.update("reset"))

        # LAYOUT

        self.directory_path_label.grid(row=2, column=0, sticky=W)
        self.directory_path_text.grid(row=2, column=1, columnspan=3, sticky=E)
        self.browse_button.grid(row=2, column=4)

        self.bins_label.grid(row=4, column=0)
        self.entry.grid(row=4, column=1, columnspan=3, sticky=W + E)

        self.build_button.grid(row=6, column=1)
        self.classify_button.grid(row=8, column=1)

    def validate(self, new_text):
        if not new_text:  # the field is being cleared
            self.entered_number = 0
            return True

        try:
            self.entered_number = int(new_text)
            return True
        except ValueError:
            return False

    def build(self):
        builderClass = builder.builder()
        trainData = builder.builder.startBuild(builderClass,
                                               self.directory_path_text.get(),
                                               self.entered_number)
        print trainData
        tkMessageBox.showinfo("Naive Bayes Classifier",
                              "Building classifier using train-set is done!")

    def checkValidate(self):
        bins = False
        structure = False
        train = False
        test = False

        if self.entry.get() != "":
            bins = True

        for file in os.listdir(self.directory_path_text.get()):
            if "Structure.txt" in file:
                structure = True
            if "train.csv" in file:
                train = True
            if "test.csv" in file:
                test = True

        if (structure == False):
            tkMessageBox.showinfo("Naive Bayes Classifier",
                                  "The file 'Structure.txt' is missing")

        if (train == False):
            tkMessageBox.showinfo("Naive Bayes Classifier",
                                  "The file 'train.csv' is missing")

        if (test == False):
            tkMessageBox.showinfo("Naive Bayes Classifier",
                                  "The file 'test.csv' is missing")

        if (bins == False):
            tkMessageBox.showinfo(
                "Naive Bayes Classifier",
                "You have to enter a number for the Discretization bins")

        if (test == True & train == True & structure == True & bins == True):
            self.build()
Beispiel #37
0
from Tkinter import Tk, Label, Entry, Button, StringVar
from tkMessageBox import showinfo

my_app = Tk(className='Kalkulator')

L1 = Label(my_app, text='Angka 1 : ')
L1.grid(row=0, column=0)
str1 = StringVar()
E1 = Entry(my_app, textvariable=str1)
E1.grid(columnspan=3, row=0, column=1)

L2 = Label(my_app, text='Angka 2 : ')
L2.grid(row=1, column=0)
str2 = StringVar()
E2 = Entry(my_app, textvariable=str2)
E2.grid(columnspan=3, row=1, column=1)


def tambah():
    p = float(str1.get())
    q = float(str2.get())
    r = p + q
    L.config(text=r)


def kurang():
    p = float(str1.get())
    q = float(str2.get())
    r = p - q
    L.config(text=r)
Beispiel #38
0
	def __init__(self, master):
		master.title('Univention Lizenz Generator')
		self.master = master
		self.logoframe = Frame(self.master, bg='red')
		self.logoframe.pack(side=TOP, fill=X, expand=YES)
		self.lftopframes = LabelFrame(self.master)
		self.lftopframes.pack(side=TOP, fill=X, expand=YES)
		self.lframe = Frame(self.lftopframes)
		self.rframe = Frame(self.lftopframes)
		self.lframe.pack(side=LEFT, fill=X, expand=YES)
		self.rframe.pack(side=RIGHT, fill=X, expand=YES)

		self.bframe = Frame(self.master)
		self.bframe.pack(fill=X)

		self.kname = StringVar()
		self.kname.set('test')

		self.chkevar = IntVar()
		self.chkevar.set('1')
		self.chkivar = IntVar()
		self.chkovar = IntVar()
		self.chkdvar = IntVar()

		self.exday = StringVar()
		self.exmonth = StringVar()
		self.exyear = StringVar()
		self.getdate()  # set date to localdate (month+3)

		try:
			self.logo = PhotoImage(file='/var/www/head_logo.gif')
		except TclError:  # fall back to 64x64 white
			self.logo = PhotoImage(data='R0lGODdhQABAAIAAAP///wAAACwAAAAAQABAAAACRYSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrhdQAAA7')
		# self.logo.pack() #muss man nicht packen??!!
		self.logolabel = Label(self.logoframe, image=self.logo, bg='#CC3300')
		self.logolabel.pack(side=LEFT, fill=X, expand=YES)

		self.lfname = LabelFrame(self.lframe, font=("Helvetica", 11), text='Kundenname:')
		self.lfname.pack(fill=X)
		self.ekname = Entry(self.lfname, textvariable=self.kname, width=30)
		self.ekname.pack(side=LEFT)

		self.lfdate = LabelFrame(self.lframe, font=("Helvetica", 11), text='Ablaufdatum (TT/MM/JJ):')
		self.lfdate.pack(fill=X)
		self.eexd = Entry(self.lfdate, textvariable=self.exday, width=2)
		self.eexd.pack(side=LEFT)
		self.eexm = Entry(self.lfdate, textvariable=self.exmonth, width=2)
		self.eexm.pack(side=LEFT)
		self.eexy = Entry(self.lfdate, textvariable=self.exyear, width=2)
		self.eexy.pack(side=LEFT)
		self.chkdate = Checkbutton(self.lfdate, text='Unbeschränkt', variable=self.chkdvar)
		self.chkdate.pack(side=RIGHT)

		self.lfchke = LabelFrame(self.lframe, font=("Helvetica", 11), text='Evaluationslizenz:')
		self.lfchke.pack(fill=X)
		self.chke = Checkbutton(self.lfchke, variable=self.chkevar)
		self.chke.pack(side=LEFT)

		self.lfchki = LabelFrame(self.lframe, font=("Helvetica", 11), text='Interne Lizenz:')
		self.lfchki.pack(fill=X)
		self.chki = Checkbutton(self.lfchki, variable=self.chkivar)
		self.chki.pack(side=LEFT)

		self.lfchko = LabelFrame(self.lframe, font=("Helvetica", 11), text='Altes Lizenzformat (vor 1.2-3):')
		self.lfchko.pack(fill=X)
		self.chko = Checkbutton(self.lfchko, variable=self.chkovar, command=self.makegrey)
		self.chko.pack(side=LEFT)

		self.kdn = StringVar()
		self.kdn.set('dc=univention,dc=de')
		self.lfdn = LabelFrame(self.rframe, font=("Helvetica", 11), text='Kunde DN:')
		self.lfdn.pack(fill=X)
		self.ekdn = Entry(self.lfdn, textvariable=self.kdn, width=30)
		self.ekdn.pack(side=LEFT)

		self.kmaxacc = IntVar()
		self.kmaxacc.set('999')
		self.kmaxgacc = IntVar()
		self.kmaxgacc.set('999')
		self.kmaxcli = IntVar()
		self.kmaxcli.set('999')
		self.kmaxdesk = IntVar()
		self.kmaxdesk.set('999')

		self.chkmaxaccvar = IntVar()
		self.chkmaxaccvar.set('0')
		self.chkmaxgaccvar = IntVar()
		self.chkmaxgaccvar.set('0')
		self.chkmaxclivar = IntVar()
		self.chkmaxclivar.set('0')
		self.chkmaxdeskvar = IntVar()
		self.chkmaxdeskvar.set('0')

		self.lfmaxacc = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Accounts:')
		self.lfmaxacc.pack(fill=X)
		self.lfmaxgacc = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Groupware Accounts:')
		self.lfmaxgacc.pack(fill=X)
		self.lfmaxcli = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Clients:')
		self.lfmaxcli.pack(fill=X)
		self.lfmaxdesk = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Univention Desktops:')
		self.lfmaxdesk.pack(fill=X)

		self.emaxacc = Entry(self.lfmaxacc, textvariable=self.kmaxacc)
		self.emaxacc.pack(side=LEFT)
		self.chkmaxacc = Checkbutton(self.lfmaxacc, text='Unbeschränkt', variable=self.chkmaxaccvar)
		self.chkmaxacc.pack(side=LEFT)

		self.emaxgacc = Entry(self.lfmaxgacc, textvariable=self.kmaxgacc)
		self.emaxgacc.pack(side=LEFT)
		self.chkmaxgacc = Checkbutton(self.lfmaxgacc, text='Unbeschränkt', variable=self.chkmaxgaccvar)
		self.chkmaxgacc.pack(side=LEFT)

		self.emaxcli = Entry(self.lfmaxcli, textvariable=self.kmaxcli)
		self.emaxcli.pack(side=LEFT)
		self.chkmaxcli = Checkbutton(self.lfmaxcli, text='Unbeschränkt', variable=self.chkmaxclivar)
		self.chkmaxcli.pack(side=LEFT)

		self.emaxdesk = Entry(self.lfmaxdesk, textvariable=self.kmaxdesk)
		self.emaxdesk.pack(side=LEFT)
		self.chkmaxdesk = Checkbutton(self.lfmaxdesk, text='Unbeschränkt', variable=self.chkmaxdeskvar)
		self.chkmaxdesk.pack(side=LEFT)

		self.bexit = Button(self.bframe, text='Beenden', command=self.quit)
		self.bexit.pack(side=RIGHT)

		self.bsave = Button(self.bframe, text='Lizenz erzeugen', command=self.generate)
		self.bsave.pack(side=RIGHT)
Beispiel #39
0
    os.system('python recognition.py')


# Use here a nice ttf font
font = ImageFont.truetype("arial.ttf", 32)
width_text, height_text = font.getsize(text)
draw.text((480, 30), text, fill="white", font=font)

#line="---------------------------------------------"
#draw.text((600, 100), line, fill="white", font=font)

#width_text, height_text = draw.textsize(text)
#draw.text((684 , 100), text, fill="black")

photoimage = ImageTk.PhotoImage(image)
Label(mainWindow, image=photoimage).place(x=-2, y=-2)

#Instanciating buttons

# load = Image.open("linev.png")
# render = ImageTk.PhotoImage(load)
# img = Label(mainWindow, image=render)
# img.image = render
# img.place(x=-2, y=2)

# load = Image.open("linev.png")
# render = ImageTk.PhotoImage(load)
# img = Label(mainWindow, image=render)
# img.image = render
# img.place(x=2, y=75)
Beispiel #40
0
    def __init__(self, master):
        
	self.fname=""
        #global variables
        self.t1=StringVar()
        self.t2=StringVar()
        self.t3=StringVar()
        self.t4=StringVar()
        self.t5=StringVar()
        self.t6=StringVar()
        self.t7=StringVar()
        self.t8=StringVar()
        
        self.var1=StringVar()
        self.var2=StringVar()
        self.var3=StringVar()
        self.var4=StringVar()
        self.var5=StringVar()
        self.var6=StringVar()
        self.var7=StringVar()
        self.var8=StringVar()
       
        #end
        
        mymaster = Frame(master, name='mymaster') # create Frame in "root"
        mymaster.pack(fill=BOTH)
        #min and max size of window    
        #master.minsize(width=900, height=900)
        #master.maxsize(width=650, height=500)
        #end
        
        #title of window
        master.title("Airdecloak-ng")
        #end
        
        #for the style of fonts
        self.customFont = tkFont.Font(family="Helvetica", size=12)
        self.myfont = tkFont.Font(family="Helvetica", size=10)
        self.myfont2 = tkFont.Font(family="Helvetica", size=8)
        self.headerfont=tkFont.Font(family="Helvetica", size=15,underline = True)
        self.myfontnew=tkFont.Font(family="Helvetica", size=11,underline = True)
        #end
        
        
       
        nb = Notebook(mymaster, name='nb') # create Notebook in "master"
        nb.pack(fill=BOTH, padx=2, pady=3) # fill "master" but pad sides
        #content frame
        self.frame_content = Frame(nb,name="frame_content", bg="white")
        self.frame_content.pack(fill=BOTH, side=TOP, expand=True)
        nb.add(self.frame_content, text="Page1") # add tab to Notebook
    
        # repeat for each tab
        self.frame_content7 = Frame(nb, name='frame_content7', bg="white")
        nb.add(self.frame_content7, text="Detect Devices")
        self.frame_content5 = Frame(nb, name='frame_content5', bg="white")
        nb.add(self.frame_content5, text="output")
        
        #End
        
	#frame content 7
	Label(self.frame_content7, text = 'Airdecloak-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        btndetect=Button(self.frame_content7, text = 'Detect', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 1, column = 0, padx = 5, pady = 5)
		
	btndbrowse=Button(self.frame_content7, text = 'Attach File', command =self.browse_file, height=2, width=15, font=self.customFont).grid(row = 3, column = 0, padx = 5, pady = 5)	
	self.lilnew1=Listbox(self.frame_content7,bg="black", fg="white", font=self.myfont, selectmode=SINGLE, width=30, height=15)
        self.lilnew1.grid(row = 1, column = 1, rowspan=3)
	#End

        Label(self.frame_content, text = 'Airdecloak-ng',font=self.headerfont, bg="white", padx=10, pady=10).grid(row = 0, column = 0)
        Label(self.frame_content, text = 'Options :',font=self.myfontnew, bg="white").grid(row = 1, column = 1)
        #Button(self.frame_content, text = 'ivs', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 0, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'gpsd', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 1, padx = 5, pady = 5)
        #Button(self.frame_content, text = 'write', command =self.canvas_detect, height=2, width=15, font=self.customFont).grid(row = 2, column = 2, padx = 5, pady = 5)
        #command Listbox
        Label(self.frame_content5, text = 'Edit Command From Here',font=self.myfontnew, bg="white", justify=LEFT).grid(row = 0, column = 0)
        TextCommandBox=Text(self.frame_content5, height=5, width=30)
        TextCommandBox.grid(row=1, column=0, padx=5, pady=5)
        self.output=Text(self.frame_content5,bg="black", fg="white", font=self.myfont, height=20, width=42)
        self.output.grid(row = 0, column = 1, padx=50, pady=5, rowspan=3)
        btnsubmit=Button(self.frame_content5, width=15, height=2, text="Get Result", command=self.mycallback)
        btnsubmit.grid(row=2, column=0)
        btnclear=Button(self.frame_content5, width=15, height=2, text="Clear Output", command=self.clearoutput)
        btnclear.grid(row=3, column=0)
        #end
        self.C1 = Checkbutton(self.frame_content, text = "-i", \
                 onvalue = "-i", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var1)
        self.C1.grid(row = 2, column = 0, padx = 5, pady = 5)
        self.t1=Text(self.frame_content,height=1,width = 20)
        self.t1.grid(row = 2, column = 1, padx = 5, pady = 5)
        l1=Label(self.frame_content, text = ': Input capture file',font=self.myfont, bg="white", justify=LEFT).grid(row = 2, column = 2, padx = 5, pady = 5)
        
        self.C2 = Checkbutton(self.frame_content, text = "--ssid", \
                 onvalue = "--ssid", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var2)
        self.C2.grid(row = 3, column = 0, padx = 5, pady = 5)
        self.t2=Text(self.frame_content,height=1,width = 20)
        self.t2.grid(row = 3, column = 1, padx = 5, pady = 5)
        l2=Label(self.frame_content, text = ': ESSID of the network to filter',font=self.myfont, bg="white", justify=LEFT).grid(row = 3, column = 2, padx = 5, pady = 5)
        
        self.C3 = Checkbutton(self.frame_content, text = "--bssid", \
                 onvalue = "--bssid", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var3)
        self.C3.grid(row = 4, column = 0, padx = 5, pady = 5)
        self.t3=Text(self.frame_content,height=1,width = 20)
        self.t3.grid(row = 4, column = 1, padx = 5, pady = 5)
        l3=Label(self.frame_content, text = ': BSSID of the network to filter',font=self.myfont, bg="white", justify=LEFT).grid(row = 4, column = 2, padx = 5, pady = 5)
        
        self.C4 = Checkbutton(self.frame_content, text = "--filters", \
                 onvalue = "--filters", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var4)
        self.C4.grid(row = 5, column = 0, padx = 5, pady = 5)
        self.t4=Text(self.frame_content,height=1,width = 20)
        self.t4.grid(row = 5, column = 1, padx = 5, pady = 5)
        l4=Label(self.frame_content, text = ': Apply filters (separated by a comma)',font=self.myfont, bg="white", justify=LEFT).grid(row = 5, column = 2, padx = 5, pady = 5)
        
        self.C5 = Checkbutton(self.frame_content, text = "--null-packets", \
                 onvalue = "--null-packets", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var5)
        self.C5.grid(row = 6, column = 0, padx = 5, pady = 5)
        self.t5=Text(self.frame_content,height=1,width = 20)
        self.t5.grid(row = 6, column = 1, padx = 5, pady = 5)
        l5=Label(self.frame_content, text = ': Assume that null packets can be cloaked.',font=self.myfont, bg="white", justify=LEFT).grid(row = 6, column = 2, padx = 5, pady = 5)
        
        self.C6 = Checkbutton(self.frame_content, text = "--disable-base_filter", \
                 onvalue = "--disable-base_filter", offvalue = "", height=1, \
                 bg="white", font=self.customFont,variable=self.var6)
        self.C6.grid(row = 8, column = 0, padx = 5, pady = 5)
        self.t6=Text(self.frame_content,height=1,width = 20)
        self.t6.grid(row = 8, column = 1, padx = 5, pady = 5)
        l6=Label(self.frame_content, text = ': Do not apply base filter.',font=self.myfont, bg="white", justify=LEFT).grid(row = 8, column = 2, padx = 5, pady = 5)
        
        self.C7 = Checkbutton(self.frame_content, text = "--drop-frag", \
                 onvalue = "--drop-frag", offvalue = "", height=1, \
                 width = 7, bg="white", font=self.customFont,variable=self.var7)
        self.C7.grid(row = 9, column = 0, padx = 5, pady = 5)
        self.t7=Text(self.frame_content,height=1,width = 20)
        self.t7.grid(row = 9, column = 1, padx = 5, pady = 5)
        l7=Label(self.frame_content, text = ': Drop fragmented packets',font=self.myfont, bg="white", justify=LEFT).grid(row = 9, column = 2, padx = 5, pady = 5)
        
        self.C8 = Checkbutton(self.frame_content, text = "--help", \
                onvalue = "--help", offvalue = "", height=1, \
                width = 7, bg="white", font=self.customFont,variable=self.var8)
        self.C8.grid(row = 10, column = 0, padx = 5, pady = 5)
        self.t8=Text(self.frame_content,height=1,width = 20)
        self.t8.grid(row = 10, column = 1, padx = 5, pady = 5)
        l8=Label(self.frame_content, text = ': Displays this usage screen',font=self.myfont, bg="white", justify=LEFT).grid(row = 10, column = 2, padx = 5, pady = 5)
Beispiel #41
0
    for i in range(len(x_array)):
        if x_array[i] > 0 and y_array[i] > 0:
            quadrant1 += 1
        elif x_array[i] < 0 and y_array[i] > 0:
            quadrant2 += 1
        elif x_array[i] < 0 and y_array[i] < 0:
            quadrant3 += 1
        elif x_array[i] > 0 and y_array[i] < 0:
            quadrant4 += 1


    tkMessageBox.showinfo('Stats', 'All frames: ' + str(len(x_array_convolved)) + '\n' + \
     'In center ' + str(centerRadius) + ' cm: ' + str(centerFrames) + '(~' + \
     str(round((float(centerFrames)/float(len(x_array_convolved))*100), 2)) + '%) \n' \
      + 'Quadrants(1-2-3-4): \n' + str(round(float(quadrant1)/float(len(x_array_convolved)), 2)) + \
      '\n' + str(round(float(quadrant2)/float(len(x_array_convolved)), 2)) + '\n' + \
     str(round(float(quadrant3)/float(len(x_array_convolved)), 2)) + '\n' + \
     str(round(float(quadrant4)/float(len(x_array_convolved)), 2)))


root = Tk()
data_path = StringVar()
data_path.set('...')
Button(text='Open', command=f_open).pack()
Label(textvariable=data_path).pack()
Button(text='Trajectory', command=showTrajectory).pack()
Button(text='Matrix',
       command=lambda: matrix((matrixDimenstion, matrixDimenstion))).pack()
Button(text='Add another file to matrix', command=addDataFile).pack()
Button(text='Cage parts', command=cageParts).pack()
root.mainloop()
Beispiel #42
0
class tkLicenseGen:

	def __init__(self, master):
		master.title('Univention Lizenz Generator')
		self.master = master
		self.logoframe = Frame(self.master, bg='red')
		self.logoframe.pack(side=TOP, fill=X, expand=YES)
		self.lftopframes = LabelFrame(self.master)
		self.lftopframes.pack(side=TOP, fill=X, expand=YES)
		self.lframe = Frame(self.lftopframes)
		self.rframe = Frame(self.lftopframes)
		self.lframe.pack(side=LEFT, fill=X, expand=YES)
		self.rframe.pack(side=RIGHT, fill=X, expand=YES)

		self.bframe = Frame(self.master)
		self.bframe.pack(fill=X)

		self.kname = StringVar()
		self.kname.set('test')

		self.chkevar = IntVar()
		self.chkevar.set('1')
		self.chkivar = IntVar()
		self.chkovar = IntVar()
		self.chkdvar = IntVar()

		self.exday = StringVar()
		self.exmonth = StringVar()
		self.exyear = StringVar()
		self.getdate()  # set date to localdate (month+3)

		try:
			self.logo = PhotoImage(file='/var/www/head_logo.gif')
		except TclError:  # fall back to 64x64 white
			self.logo = PhotoImage(data='R0lGODdhQABAAIAAAP///wAAACwAAAAAQABAAAACRYSPqcvtD6OctNqLs968+w+G4kiW5omm6sq27gvH8kzX9o3n+s73/g8MCofEovGITCqXzKbzCY1Kp9Sq9YrNarfcrhdQAAA7')
		# self.logo.pack() #muss man nicht packen??!!
		self.logolabel = Label(self.logoframe, image=self.logo, bg='#CC3300')
		self.logolabel.pack(side=LEFT, fill=X, expand=YES)

		self.lfname = LabelFrame(self.lframe, font=("Helvetica", 11), text='Kundenname:')
		self.lfname.pack(fill=X)
		self.ekname = Entry(self.lfname, textvariable=self.kname, width=30)
		self.ekname.pack(side=LEFT)

		self.lfdate = LabelFrame(self.lframe, font=("Helvetica", 11), text='Ablaufdatum (TT/MM/JJ):')
		self.lfdate.pack(fill=X)
		self.eexd = Entry(self.lfdate, textvariable=self.exday, width=2)
		self.eexd.pack(side=LEFT)
		self.eexm = Entry(self.lfdate, textvariable=self.exmonth, width=2)
		self.eexm.pack(side=LEFT)
		self.eexy = Entry(self.lfdate, textvariable=self.exyear, width=2)
		self.eexy.pack(side=LEFT)
		self.chkdate = Checkbutton(self.lfdate, text='Unbeschränkt', variable=self.chkdvar)
		self.chkdate.pack(side=RIGHT)

		self.lfchke = LabelFrame(self.lframe, font=("Helvetica", 11), text='Evaluationslizenz:')
		self.lfchke.pack(fill=X)
		self.chke = Checkbutton(self.lfchke, variable=self.chkevar)
		self.chke.pack(side=LEFT)

		self.lfchki = LabelFrame(self.lframe, font=("Helvetica", 11), text='Interne Lizenz:')
		self.lfchki.pack(fill=X)
		self.chki = Checkbutton(self.lfchki, variable=self.chkivar)
		self.chki.pack(side=LEFT)

		self.lfchko = LabelFrame(self.lframe, font=("Helvetica", 11), text='Altes Lizenzformat (vor 1.2-3):')
		self.lfchko.pack(fill=X)
		self.chko = Checkbutton(self.lfchko, variable=self.chkovar, command=self.makegrey)
		self.chko.pack(side=LEFT)

		self.kdn = StringVar()
		self.kdn.set('dc=univention,dc=de')
		self.lfdn = LabelFrame(self.rframe, font=("Helvetica", 11), text='Kunde DN:')
		self.lfdn.pack(fill=X)
		self.ekdn = Entry(self.lfdn, textvariable=self.kdn, width=30)
		self.ekdn.pack(side=LEFT)

		self.kmaxacc = IntVar()
		self.kmaxacc.set('999')
		self.kmaxgacc = IntVar()
		self.kmaxgacc.set('999')
		self.kmaxcli = IntVar()
		self.kmaxcli.set('999')
		self.kmaxdesk = IntVar()
		self.kmaxdesk.set('999')

		self.chkmaxaccvar = IntVar()
		self.chkmaxaccvar.set('0')
		self.chkmaxgaccvar = IntVar()
		self.chkmaxgaccvar.set('0')
		self.chkmaxclivar = IntVar()
		self.chkmaxclivar.set('0')
		self.chkmaxdeskvar = IntVar()
		self.chkmaxdeskvar.set('0')

		self.lfmaxacc = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Accounts:')
		self.lfmaxacc.pack(fill=X)
		self.lfmaxgacc = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Groupware Accounts:')
		self.lfmaxgacc.pack(fill=X)
		self.lfmaxcli = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Clients:')
		self.lfmaxcli.pack(fill=X)
		self.lfmaxdesk = LabelFrame(self.rframe, font=("Helvetica", 11), text='Max. Univention Desktops:')
		self.lfmaxdesk.pack(fill=X)

		self.emaxacc = Entry(self.lfmaxacc, textvariable=self.kmaxacc)
		self.emaxacc.pack(side=LEFT)
		self.chkmaxacc = Checkbutton(self.lfmaxacc, text='Unbeschränkt', variable=self.chkmaxaccvar)
		self.chkmaxacc.pack(side=LEFT)

		self.emaxgacc = Entry(self.lfmaxgacc, textvariable=self.kmaxgacc)
		self.emaxgacc.pack(side=LEFT)
		self.chkmaxgacc = Checkbutton(self.lfmaxgacc, text='Unbeschränkt', variable=self.chkmaxgaccvar)
		self.chkmaxgacc.pack(side=LEFT)

		self.emaxcli = Entry(self.lfmaxcli, textvariable=self.kmaxcli)
		self.emaxcli.pack(side=LEFT)
		self.chkmaxcli = Checkbutton(self.lfmaxcli, text='Unbeschränkt', variable=self.chkmaxclivar)
		self.chkmaxcli.pack(side=LEFT)

		self.emaxdesk = Entry(self.lfmaxdesk, textvariable=self.kmaxdesk)
		self.emaxdesk.pack(side=LEFT)
		self.chkmaxdesk = Checkbutton(self.lfmaxdesk, text='Unbeschränkt', variable=self.chkmaxdeskvar)
		self.chkmaxdesk.pack(side=LEFT)

		self.bexit = Button(self.bframe, text='Beenden', command=self.quit)
		self.bexit.pack(side=RIGHT)

		self.bsave = Button(self.bframe, text='Lizenz erzeugen', command=self.generate)
		self.bsave.pack(side=RIGHT)

	def generate(self):
		makelicense = ['univention_make_license']
		path = tkFileDialog.asksaveasfilename(initialdir='~', initialfile=self.kname.get() + '-license', defaultextension='.ldif')
		# print path
		if path:
			if self.chkevar.get():
				makelicense.append('-e')
			if self.chkivar.get():
				makelicense.append('-i')
			makelicense.append('-f')
			makelicense.append(path)

			if not self.chkdvar.get():
				makelicense.append('-d')
				makelicense.append("%s/%s/%s" % (self.exmonth.get(), self.exday.get(), self.exyear.get()))

			if not self.chkovar.get():
				if not self.chkmaxaccvar.get():
					makelicense.append('-a')
					makelicense.append('%d' % self.kmaxacc.get())
				else:
					makelicense.append('-a')
					makelicense.append('unlimited')
				if not self.chkmaxgaccvar.get():
					makelicense.append('-g')
					makelicense.append('%d' % self.kmaxgacc.get())
				else:
					makelicense.append('-g')
					makelicense.append('unlimited')
				if not self.chkmaxclivar.get():
					makelicense.append('-c')
					makelicense.append('%d' % self.kmaxcli.get())
				else:
					makelicense.append('-c')
					makelicense.append('unlimited')
				if not self.chkmaxdeskvar.get():
					makelicense.append('-u')
					makelicense.append('%d' % self.kmaxdesk.get())
				else:
					makelicense.append('-u')
					makelicense.append('unlimited')
			else:
				makelicense.append('-o')

			makelicense.append(self.kname.get())
			makelicense.append(self.kdn.get())
			os.chdir('/home/groups/99_license/')
			p = subprocess.Popen(makelicense, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
			stdout, stderr = p.communicate()
			if p.returncode == 0:
				showinfo('Lizenz Erstellt!', 'Die Lizenz für %s wurde erfolgreich erstellt!' % self.kname.get())
			elif p.returncode == 257:
				showerror('Fehler', 'Errorcode: "%s"\nEvtl. sind Sie nicht in dem Sudoers File!' % p.returncode)
			elif p.returncode == 8704:
				showerror('Fehler', 'Errorcode: "%s"\nmake_license.sh meldet: "invalid DN"!' % p.returncode)
			else:
				print >>sys.stderr, '%r\n%s' % (makelicense, stdout)
				showerror('Fehler', 'Errorcode: "%s"\nEin unbekannter Fehler ist aufgetreten!\nBitte senden Sie eine komplette Fehlerbeschreibung an "*****@*****.**"' % p.returncode)
			# print makelicense
			# print '-->ErrorCode: %d'%i[0]
			# print i[1]

	def getdate(self):
		localtime = time.strftime('%d %m %y')
		split = localtime.split(' ')
		day = int(split[0])
		month = int(split[1])
		year = int(split[2])
		month += 3
		if month > 12:
			month = month - 12
			year += 1
		if day < 10:
			day = '0' + str(day)
		if month < 10:
			month = '0' + str(month)
		if year < 10:
			year = '0' + str(year)
		self.exday.set(day)
		self.exmonth.set(month)
		self.exyear.set(year)

	def makegrey(self):
		pass

	def quit(self, event=None):
		self.master.quit()
Beispiel #43
0
    def click_reaction(self, event=None):

        try:
            self.equationwidget.grid_forget()
            self.ratewidget.grid_forget()
        except:
            pass

        try:
            self.lamcoeflabel.grid_forget()
            self.lamcoefwidget.grid_forget()
            self.lamunitlabel.grid_forget()
        except:
            pass

        coefficient = self.coefficients[self.layer.get()][self.reaction.get()]
        self.lam.set(coefficient.lam)

        self.equation = coefficient.reaction.equation
        self.equationwidget = Label(self.frame,
                                    text=self.equation,
                                    font=self.formulatype)
        self.equationwidget.grid(row=4, column=3, padx=5)

        if coefficient.reaction.model == 'User-defined' or coefficient.reaction.model == 'Fundamental':

            unitindex = 0

            tkfont = tkFont.Font(font=self.formulatype)
            tksubfont = tkFont.Font(font=self.subfont)
            tksuperfont = tkFont.Font(font=self.superfont)

            # Measure the width of rate and lambda expression
            rate_len = tkfont.measure(u'r = \u03BB')
            rate_len = rate_len + tksubfont.measure(
                str(coefficient.reaction.number) + ',')
            if coefficient.layer.number == 0:
                rate_len = rate_len + tksubfont.measure('D')
            else:
                rate_len = rate_len + tksubfont.measure(
                    str(coefficient.layer.number))
            for reactant in coefficient.reaction.reactants:
                if reactant.index <> 0:
                    rate_len = rate_len + tkfont.measure('C')
                    rate_len = rate_len + tksubfont.measure(reactant.formula)
                    if reactant.index == int(reactant.index):
                        index = int(reactant.index)
                    else:
                        index = reactant.index

                    if index <> 1.:
                        rate_len = rate_len + tksuperfont.measure(
                            str(index) + ' ')
                    unitindex = unitindex + reactant.index

            lam_len = tkfont.measure('')
            if unitindex == int(unitindex): unitindex = int(unitindex)
            if (unitindex - 1) != 0:
                if (unitindex - 1) != 1:
                    lam_len = lam_len + tkfont.measure('(' + self.concunit +
                                                       ')')
                    lam_len = lam_len + tksuperfont.measure(
                        str(-(unitindex - 1)))
                else:
                    lam_len = lam_len + tkfont.measure(self.concunit)
            lam_len = lam_len + tkfont.measure(self.timeunit)
            lam_len = lam_len + tksuperfont.measure('-1')

            self.ratewidget = Text(self.frame,
                                   width=int(rate_len * 1.1424219345 / 8) + 1,
                                   height=1,
                                   font=self.formulatype)
            self.ratewidget.insert('end', u'r = \u03BB')
            self.ratewidget.insert('end',
                                   str(coefficient.reaction.number) + ',',
                                   'sub')
            if coefficient.layer.number == 0:
                self.ratewidget.insert('end', 'D', 'sub')
            else:
                self.ratewidget.insert('end', str(coefficient.layer.number),
                                       'sub')
            for reactant in coefficient.reaction.reactants:
                if reactant.index <> 0:
                    self.ratewidget.insert('end', 'C')
                    self.ratewidget.insert('end', reactant.formula, 'sub')
                    if reactant.index == int(reactant.index):
                        index = int(reactant.index)
                    else:
                        index = reactant.index
                    if index <> 1.:
                        self.ratewidget.insert('end',
                                               str(index) + ' ', 'super')

            self.ratewidget.tag_config('sub', offset=-4, font=self.subfont)
            self.ratewidget.tag_config('super', offset=5, font=self.superfont)
            self.ratewidget.tag_config('right', justify='right')
            self.ratewidget.config(state='disabled',
                                   background=self.bgcolor,
                                   borderwidth=0,
                                   spacing3=3)

            self.lamcoefwidget = Entry(self.frame,
                                       textvariable=self.lam,
                                       justify='center',
                                       width=8)

            self.lamunitlabel = Text(self.frame,
                                     width=int(lam_len * 1.1424219345 / 8) + 1,
                                     height=1,
                                     font=self.formulatype)
            if unitindex == int(unitindex): unitindex = int(unitindex)
            if (unitindex - 1) != 0:
                if (unitindex - 1) != 1:
                    self.lamunitlabel.insert('end', '(' + self.concunit + ')')
                    self.lamunitlabel.insert('end', str(-(unitindex - 1)),
                                             'super')
                else:
                    self.lamunitlabel.insert('end', self.concunit)
            self.lamunitlabel.insert('end', self.timeunit)
            self.lamunitlabel.insert('end', '-1', 'super')
            self.lamunitlabel.tag_config('sub', offset=-4, font=self.subfont)
            self.lamunitlabel.tag_config('super',
                                         offset=5,
                                         font=self.superfont)
            self.lamunitlabel.tag_config('right', justify='right')
            self.lamunitlabel.config(state='disabled',
                                     background=self.bgcolor,
                                     borderwidth=0,
                                     spacing3=3)

            self.lamcoeflabel.grid(row=2,
                                   column=5,
                                   padx=2,
                                   sticky='WE',
                                   columnspan=4)

            self.ratewidget.grid(row=4, column=4, padx=5)
            self.lamcoefwidget.grid(row=4, column=5, padx=2, sticky='E')
            self.lamunitlabel.grid(row=4, column=6, padx=2, sticky='W')

        self.frame.update()
        self.focusbutton = None
        self.master.geometry()
        self.master.center()
Beispiel #44
0
class CallTip:
    def __init__(self, widget):
        self.widget = widget
        self.tipwindow = self.label = None
        self.parenline = self.parencol = None
        self.lastline = None
        self.hideid = self.checkhideid = None
        self.checkhide_after_id = None

    def position_window(self):
        """Check if needs to reposition the window, and if so - do it."""
        curline = int(self.widget.index("insert").split('.')[0])
        if curline == self.lastline:
            return
        self.lastline = curline
        self.widget.see("insert")
        if curline == self.parenline:
            box = self.widget.bbox("%d.%d" % (self.parenline, self.parencol))
        else:
            box = self.widget.bbox("%d.0" % curline)
        if not box:
            box = list(self.widget.bbox("insert"))
            # align to left of window
            box[0] = 0
            box[2] = 0
        x = box[0] + self.widget.winfo_rootx() + 2
        y = box[1] + box[3] + self.widget.winfo_rooty()
        self.tipwindow.wm_geometry("+%d+%d" % (x, y))

    def showtip(self, text, parenleft, parenright):
        """Show the calltip, bind events which will close it and reposition it.
        """
        # Only called in CallTips, where lines are truncated
        self.text = text
        if self.tipwindow or not self.text:
            return

        self.widget.mark_set(MARK_RIGHT, parenright)
        self.parenline, self.parencol = map(
            int,
            self.widget.index(parenleft).split("."))

        self.tipwindow = tw = Toplevel(self.widget)
        self.position_window()
        # remove border on calltip window
        tw.wm_overrideredirect(1)
        try:
            # This command is only needed and available on Tk >= 8.4.0 for OSX
            # Without it, call tips intrude on the typing process by grabbing
            # the focus.
            tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
                       "help", "noActivates")
        except TclError:
            pass
        self.label = Label(tw,
                           text=self.text,
                           justify=LEFT,
                           background="#ffffe0",
                           relief=SOLID,
                           borderwidth=1,
                           font=self.widget['font'])
        self.label.pack()
        tw.lift()  # work around bug in Tk 8.5.18+ (issue #24570)

        self.checkhideid = self.widget.bind(CHECKHIDE_VIRTUAL_EVENT_NAME,
                                            self.checkhide_event)
        for seq in CHECKHIDE_SEQUENCES:
            self.widget.event_add(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
        self.widget.after(CHECKHIDE_TIME, self.checkhide_event)
        self.hideid = self.widget.bind(HIDE_VIRTUAL_EVENT_NAME,
                                       self.hide_event)
        for seq in HIDE_SEQUENCES:
            self.widget.event_add(HIDE_VIRTUAL_EVENT_NAME, seq)

    def checkhide_event(self, event=None):
        if not self.tipwindow:
            # If the event was triggered by the same event that unbinded
            # this function, the function will be called nevertheless,
            # so do nothing in this case.
            return
        curline, curcol = map(int, self.widget.index("insert").split('.'))
        if curline < self.parenline or \
           (curline == self.parenline and curcol <= self.parencol) or \
           self.widget.compare("insert", ">", MARK_RIGHT):
            self.hidetip()
        else:
            self.position_window()
            if self.checkhide_after_id is not None:
                self.widget.after_cancel(self.checkhide_after_id)
            self.checkhide_after_id = \
                self.widget.after(CHECKHIDE_TIME, self.checkhide_event)

    def hide_event(self, event):
        if not self.tipwindow:
            # See the explanation in checkhide_event.
            return
        self.hidetip()

    def hidetip(self):
        if not self.tipwindow:
            return

        for seq in CHECKHIDE_SEQUENCES:
            self.widget.event_delete(CHECKHIDE_VIRTUAL_EVENT_NAME, seq)
        self.widget.unbind(CHECKHIDE_VIRTUAL_EVENT_NAME, self.checkhideid)
        self.checkhideid = None
        for seq in HIDE_SEQUENCES:
            self.widget.event_delete(HIDE_VIRTUAL_EVENT_NAME, seq)
        self.widget.unbind(HIDE_VIRTUAL_EVENT_NAME, self.hideid)
        self.hideid = None

        self.label.destroy()
        self.label = None
        self.tipwindow.destroy()
        self.tipwindow = None

        self.widget.mark_unset(MARK_RIGHT)
        self.parenline = self.parencol = self.lastline = None

    def is_active(self):
        return bool(self.tipwindow)
Beispiel #45
0
def Frameloop():

    #column 2

    labelt = Label(frame, textvariable=t2, font=("arial", 40))
    labelt.grid(row=0, column=2)
    labelv = Label(frame, textvariable=v2, font=("arial", 40))
    labelv.grid(row=1, column=2)
    labell = Label(frame, textvariable=l2, font=("arial", 40))
    labell.grid(row=2, column=2)
    labelz = Label(frame, textvariable=z2, font=("arial", 40))
    labelz.grid(row=3, column=2)
    frame.grid()
    root.update()
    return
Beispiel #46
0
    def make_widgets(self):

        self.instructions = Label(
            self.frame,
            text=
            'Please input the following information for the added kinetic process:        '
        )

        self.blankcolumn = Label(self.frame, text=' ', width=2)
        self.layercolumn = Label(self.frame, text=' ', width=15)
        self.namecolumn = Label(self.frame, text=' ', width=15)
        self.equationcolumn = Label(self.frame, text=' ', width=20)
        self.ratecolumn = Label(self.frame, text=' ', width=10)
        self.coef1column = Label(self.frame, text=' ', width=10)
        self.unit1column = Label(self.frame, text=' ', width=3)
        self.endcolumn = Label(self.frame, text=' ', width=2)

        self.layerlabel = Label(self.frame, text='Layer')
        self.namelabel = Label(self.frame, text='Reaction')
        self.equationlabel = Label(self.frame, text='Chemical equation')
        self.ratelabel = Label(self.frame, text='Rate equation')
        self.lamcoeflabel = Label(self.frame, text='Coefficient  ' + u'\u03BB')

        self.blank1 = Label(self.frame, text=' ')

        self.instructions.grid(row=0,
                               column=0,
                               padx=8,
                               sticky='W',
                               columnspan=11)

        self.blankcolumn.grid(row=1, column=0, padx=2, sticky='WE')
        self.layercolumn.grid(row=1, column=1, padx=2, sticky='WE')
        self.namecolumn.grid(row=1, column=2, padx=2, sticky='WE')
        self.equationcolumn.grid(row=1, column=3, padx=2, sticky='WE')
        self.ratecolumn.grid(row=1, column=4, padx=2, sticky='WE')
        self.coef1column.grid(row=1, column=5, padx=2, sticky='WE')
        self.unit1column.grid(row=1, column=6, padx=2, sticky='WE')
        self.endcolumn.grid(row=1, column=7, padx=2, sticky='WE')

        self.layerlabel.grid(row=2, column=1, padx=2, sticky='WE')
        self.namelabel.grid(row=2, column=2, padx=2, sticky='WE')
        self.equationlabel.grid(row=2, column=3, padx=2, sticky='WE')
        self.ratelabel.grid(row=2, column=4, padx=2, sticky='WE')

        self.blank1.grid(row=3, column=0, padx=2, sticky='WE', columnspan=11)

        if self.editflag == 1:

            self.layerwidget = Label(self.frame, text=self.layer)
            self.namewidget = Label(self.frame, text=self.reaction)
            self.equationwidget = Label(self.frame,
                                        text=self.equation,
                                        font=self.formulatype)

            self.layerwidget.grid(row=4, column=1, padx=2)
            self.namewidget.grid(row=4, column=2, padx=2)
            self.equationwidget.grid(row=4, column=3, padx=10)

            if self.coefficient.reaction.model == 'User-defined' or self.coefficient.reaction.model == 'Fundamental':

                unitindex = 0

                tkfont = tkFont.Font(font=self.formulatype)
                tksubfont = tkFont.Font(font=self.subfont)
                tksuperfont = tkFont.Font(font=self.superfont)

                # Measure the width of rate and lambda expression
                rate_len = tkfont.measure(u'r = \u03BB')
                rate_len = rate_len + tksubfont.measure(
                    str(self.coefficient.reaction.number) + ',')
                if self.coefficient.layer.number == 0:
                    rate_len = rate_len + tksubfont.measure('D')
                else:
                    rate_len = rate_len + tksubfont.measure(
                        str(self.coefficient.layer.number))
                for reactant in self.coefficient.reaction.reactants:
                    if reactant.index <> 0:
                        rate_len = rate_len + tkfont.measure('C')
                        rate_len = rate_len + tksubfont.measure(
                            reactant.formula)
                        if reactant.index == int(reactant.index):
                            index = int(reactant.index)
                        else:
                            index = reactant.index

                        if index <> 1.:
                            rate_len = rate_len + tksuperfont.measure(
                                str(index) + ' ')
                        unitindex = unitindex + reactant.index
                print(unitindex)
                lam_len = tkfont.measure('')
                if unitindex == int(unitindex): unitindex = int(unitindex)
                print(unitindex)
                if (unitindex - 1) != 0:
                    if (unitindex - 1) != -1:
                        lam_len = lam_len + tkfont.measure('(' +
                                                           self.concunit + ')')
                        lam_len = lam_len + tksuperfont.measure(
                            str(-(unitindex - 1)))
                    else:
                        lam_len = lam_len + tkfont.measure(self.concunit + ' ')
                lam_len = lam_len + tkfont.measure(self.timeunit)
                lam_len = lam_len + tksuperfont.measure('-1')

                self.ratewidget = Text(self.frame,
                                       width=int(rate_len * 1.1424219345 / 8) +
                                       1,
                                       height=1,
                                       font=self.formulatype)
                self.ratewidget.insert('end', u'r')
                self.ratewidget.insert('end', ' = ')
                self.ratewidget.insert('end', u'\u03BB')
                self.ratewidget.insert(
                    'end',
                    str(self.coefficient.reaction.number) + ',', 'sub')
                if self.coefficient.layer.number == 0:
                    self.ratewidget.insert('end', 'D', 'sub')
                else:
                    self.ratewidget.insert('end',
                                           str(self.coefficient.layer.number),
                                           'sub')
                for reactant in self.coefficient.reaction.reactants:
                    if reactant.index <> 0:
                        self.ratewidget.insert('end', 'C')
                        self.ratewidget.insert('end', reactant.formula, 'sub')
                        if reactant.index == int(reactant.index):
                            index = int(reactant.index)
                        else:
                            index = reactant.index
                        if index <> 1.:
                            self.ratewidget.insert('end',
                                                   str(index) + ' ', 'super')

                self.ratewidget.tag_config('sub', offset=-4, font=self.subfont)
                self.ratewidget.tag_config('super',
                                           offset=5,
                                           font=self.superfont)
                self.ratewidget.tag_config('right', justify='right')
                self.ratewidget.config(state='disabled',
                                       background=self.bgcolor,
                                       borderwidth=0,
                                       spacing3=3)

                self.lamcoefwidget = Entry(self.frame,
                                           textvariable=self.lam,
                                           justify='center',
                                           width=8)

                self.lamunitlabel = Text(
                    self.frame,
                    width=int(lam_len * 1.1424219345 / 8) + 1,
                    height=1,
                    font=self.formulatype)
                if (unitindex - 1) != 0:
                    if (unitindex - 1) != -1:
                        self.lamunitlabel.insert('end',
                                                 '(' + self.concunit + ')')
                        self.lamunitlabel.insert('end', str(-(unitindex - 1)),
                                                 'super')
                    else:
                        self.lamunitlabel.insert('end', self.concunit + ' ')
                self.lamunitlabel.insert('end', self.timeunit)
                self.lamunitlabel.insert('end', '-1', 'super')
                self.lamunitlabel.tag_config('sub',
                                             offset=-4,
                                             font=self.subfont)
                self.lamunitlabel.tag_config('super',
                                             offset=5,
                                             font=self.superfont)
                self.lamunitlabel.tag_config('right', justify='right')
                self.lamunitlabel.config(state='disabled',
                                         background=self.bgcolor,
                                         borderwidth=0,
                                         spacing3=3)

                self.lamcoeflabel.grid(row=2,
                                       column=5,
                                       padx=2,
                                       sticky='WE',
                                       columnspan=4)

                self.ratewidget.grid(row=4, column=4, padx=5)
                self.lamcoefwidget.grid(row=4, column=5, padx=2, sticky='E')
                self.lamunitlabel.grid(row=4, column=6, padx=2, sticky='W')

        else:
            self.layerwidget = OptionMenu(self.frame,
                                          self.layer,
                                          *self.layer_list,
                                          command=self.click_layer)
            self.layerwidget.grid(row=4, column=1, padx=2, sticky='WE')
            self.click_layer()

        self.okbutton = Button(self.frame,
                               text='OK',
                               width=20,
                               command=self.OK)
        self.cancelbutton = Button(self.frame,
                                   text='Cancel',
                                   width=20,
                                   command=self.Cancel)
        self.blank2 = Label(self.frame, text=' ')
        self.blank3 = Label(self.frame, text=' ')
        self.blank4 = Label(self.frame, text=' ')
        self.focusbutton = None

        self.blank3.grid(row=5)
        self.okbutton.grid(row=6, columnspan=11)
        self.cancelbutton.grid(row=7, columnspan=11)
        self.blank4.grid(row=8)
        self.okbutton.bind('<Return>', self.OK)
        self.focusbutton = self.okbutton
Beispiel #47
0
def Time():

    global Delay
    global Backup
    infof.destroy()

    varDelay = StringVar()
    varDelay.set(
        'Om de hoeveel seconden moeten er waardes genomen worden (min 2s) ?')
    placeDelay = Label(TIme, textvariable=varDelay, font=("arial,50"))
    InputDelay = Entry(TIme, textvariable=Delay)
    InputDelay.grid(row=0, column=1)
    placeDelay.grid(row=0, column=0)

    varB = StringVar()
    varB.set('Om de hoeveel waardes moet er een backup genomen worden ?')
    placeB = Label(TIme, textvariable=varB, font=("arial,50"))
    InputB = Entry(TIme, textvariable=Backup)
    InputB.grid(row=1, column=1)
    placeB.grid(row=1, column=0)

    varX = StringVar()
    varX.set('Hoelang mag het programma draaien (h m s)')
    placeX = Label(TIme, textvariable=varX, font=("arial,50"))
    InputX = Entry(TIme, textvariable=X)
    InputX.grid(row=2, column=1)
    placeX.grid(row=2, column=0)

    TIme.grid()

    button = Button(TIme, text='Next', command=Arduino2)
    button.config(font=("arial", 25))
    button.grid(row=3, column=1)
    TIme.grid()
Beispiel #48
0
class CoefficientEditor:
    """Gets the chemical reaction information for each layer."""
    def __init__(self, master, system, coefficient, coefficients, editflag):
        """Constructor method.  Makes the GUI using the list of "Layer" objects
        "layers." """

        # Read the Tkinter information
        self.master = master
        self.version = system.version
        self.fonttype = system.fonttype
        self.formulatype = system.formulatype
        self.superfont = get_superfont(self.fonttype)
        self.subfont = get_superfont(self.formulatype)
        self.tframe = Frame(master.tframe)
        self.frame = Frame(master.frame)
        self.bframe = Frame(master.bframe)
        self.bgcolor = self.frame.cget('bg')
        self.top = None

        self.concunit = system.concunit
        self.timeunit = system.timeunit

        self.concunits = system.concunits

        # Convert mass concentration units to corresponding molar concentration units
        if self.concunit == system.concunits[0]:
            self.concunit = system.concunits[3]
        if self.concunit == system.concunits[1]:
            self.concunit = system.concunits[4]
        if self.concunit == system.concunits[2]:
            self.concunit = system.concunits[5]

        # Read the system information
        self.coefficient = coefficient
        self.coefficients = coefficients
        self.layers = system.layers
        self.editflag = editflag

        if self.editflag == 0:

            self.layer_full_list = []
            self.reaction_full_list = []
            for layer in system.layers:
                self.layer_full_list.append(layer.name)
            for reaction in system.reactions:
                self.reaction_full_list.append(reaction.name)

            self.layer_list = []
            self.reaction_list = []

            for layer in system.layers:
                coef_check = 0
                for reaction in system.reactions:
                    if coefficients[layer.name][reaction.name].lam == 0:
                        coef_check = 1
                if coef_check == 1:
                    self.layer_list.append(layer.name)
                    self.reaction_list.append([])
                    for reaction in system.reactions:
                        if coefficients[layer.name][reaction.name].lam == 0:
                            self.reaction_list[-1].append(reaction.name)

            self.layer = StringVar(value=self.layer_list[0])
            self.reaction = StringVar(value=self.reaction_list[0][0])
            self.equation = StringVar(value='')

        else:
            self.layer = coefficient.layer.name
            self.reaction = coefficient.reaction.name
            self.equation = coefficient.reaction.equation
            self.reactants = coefficient.reaction.reactants

        self.lam = DoubleVar(value=coefficient.lam)

        self.cancelflag = 0

    def make_widgets(self):

        self.instructions = Label(
            self.frame,
            text=
            'Please input the following information for the added kinetic process:        '
        )

        self.blankcolumn = Label(self.frame, text=' ', width=2)
        self.layercolumn = Label(self.frame, text=' ', width=15)
        self.namecolumn = Label(self.frame, text=' ', width=15)
        self.equationcolumn = Label(self.frame, text=' ', width=20)
        self.ratecolumn = Label(self.frame, text=' ', width=10)
        self.coef1column = Label(self.frame, text=' ', width=10)
        self.unit1column = Label(self.frame, text=' ', width=3)
        self.endcolumn = Label(self.frame, text=' ', width=2)

        self.layerlabel = Label(self.frame, text='Layer')
        self.namelabel = Label(self.frame, text='Reaction')
        self.equationlabel = Label(self.frame, text='Chemical equation')
        self.ratelabel = Label(self.frame, text='Rate equation')
        self.lamcoeflabel = Label(self.frame, text='Coefficient  ' + u'\u03BB')

        self.blank1 = Label(self.frame, text=' ')

        self.instructions.grid(row=0,
                               column=0,
                               padx=8,
                               sticky='W',
                               columnspan=11)

        self.blankcolumn.grid(row=1, column=0, padx=2, sticky='WE')
        self.layercolumn.grid(row=1, column=1, padx=2, sticky='WE')
        self.namecolumn.grid(row=1, column=2, padx=2, sticky='WE')
        self.equationcolumn.grid(row=1, column=3, padx=2, sticky='WE')
        self.ratecolumn.grid(row=1, column=4, padx=2, sticky='WE')
        self.coef1column.grid(row=1, column=5, padx=2, sticky='WE')
        self.unit1column.grid(row=1, column=6, padx=2, sticky='WE')
        self.endcolumn.grid(row=1, column=7, padx=2, sticky='WE')

        self.layerlabel.grid(row=2, column=1, padx=2, sticky='WE')
        self.namelabel.grid(row=2, column=2, padx=2, sticky='WE')
        self.equationlabel.grid(row=2, column=3, padx=2, sticky='WE')
        self.ratelabel.grid(row=2, column=4, padx=2, sticky='WE')

        self.blank1.grid(row=3, column=0, padx=2, sticky='WE', columnspan=11)

        if self.editflag == 1:

            self.layerwidget = Label(self.frame, text=self.layer)
            self.namewidget = Label(self.frame, text=self.reaction)
            self.equationwidget = Label(self.frame,
                                        text=self.equation,
                                        font=self.formulatype)

            self.layerwidget.grid(row=4, column=1, padx=2)
            self.namewidget.grid(row=4, column=2, padx=2)
            self.equationwidget.grid(row=4, column=3, padx=10)

            if self.coefficient.reaction.model == 'User-defined' or self.coefficient.reaction.model == 'Fundamental':

                unitindex = 0

                tkfont = tkFont.Font(font=self.formulatype)
                tksubfont = tkFont.Font(font=self.subfont)
                tksuperfont = tkFont.Font(font=self.superfont)

                # Measure the width of rate and lambda expression
                rate_len = tkfont.measure(u'r = \u03BB')
                rate_len = rate_len + tksubfont.measure(
                    str(self.coefficient.reaction.number) + ',')
                if self.coefficient.layer.number == 0:
                    rate_len = rate_len + tksubfont.measure('D')
                else:
                    rate_len = rate_len + tksubfont.measure(
                        str(self.coefficient.layer.number))
                for reactant in self.coefficient.reaction.reactants:
                    if reactant.index <> 0:
                        rate_len = rate_len + tkfont.measure('C')
                        rate_len = rate_len + tksubfont.measure(
                            reactant.formula)
                        if reactant.index == int(reactant.index):
                            index = int(reactant.index)
                        else:
                            index = reactant.index

                        if index <> 1.:
                            rate_len = rate_len + tksuperfont.measure(
                                str(index) + ' ')
                        unitindex = unitindex + reactant.index
                print(unitindex)
                lam_len = tkfont.measure('')
                if unitindex == int(unitindex): unitindex = int(unitindex)
                print(unitindex)
                if (unitindex - 1) != 0:
                    if (unitindex - 1) != -1:
                        lam_len = lam_len + tkfont.measure('(' +
                                                           self.concunit + ')')
                        lam_len = lam_len + tksuperfont.measure(
                            str(-(unitindex - 1)))
                    else:
                        lam_len = lam_len + tkfont.measure(self.concunit + ' ')
                lam_len = lam_len + tkfont.measure(self.timeunit)
                lam_len = lam_len + tksuperfont.measure('-1')

                self.ratewidget = Text(self.frame,
                                       width=int(rate_len * 1.1424219345 / 8) +
                                       1,
                                       height=1,
                                       font=self.formulatype)
                self.ratewidget.insert('end', u'r')
                self.ratewidget.insert('end', ' = ')
                self.ratewidget.insert('end', u'\u03BB')
                self.ratewidget.insert(
                    'end',
                    str(self.coefficient.reaction.number) + ',', 'sub')
                if self.coefficient.layer.number == 0:
                    self.ratewidget.insert('end', 'D', 'sub')
                else:
                    self.ratewidget.insert('end',
                                           str(self.coefficient.layer.number),
                                           'sub')
                for reactant in self.coefficient.reaction.reactants:
                    if reactant.index <> 0:
                        self.ratewidget.insert('end', 'C')
                        self.ratewidget.insert('end', reactant.formula, 'sub')
                        if reactant.index == int(reactant.index):
                            index = int(reactant.index)
                        else:
                            index = reactant.index
                        if index <> 1.:
                            self.ratewidget.insert('end',
                                                   str(index) + ' ', 'super')

                self.ratewidget.tag_config('sub', offset=-4, font=self.subfont)
                self.ratewidget.tag_config('super',
                                           offset=5,
                                           font=self.superfont)
                self.ratewidget.tag_config('right', justify='right')
                self.ratewidget.config(state='disabled',
                                       background=self.bgcolor,
                                       borderwidth=0,
                                       spacing3=3)

                self.lamcoefwidget = Entry(self.frame,
                                           textvariable=self.lam,
                                           justify='center',
                                           width=8)

                self.lamunitlabel = Text(
                    self.frame,
                    width=int(lam_len * 1.1424219345 / 8) + 1,
                    height=1,
                    font=self.formulatype)
                if (unitindex - 1) != 0:
                    if (unitindex - 1) != -1:
                        self.lamunitlabel.insert('end',
                                                 '(' + self.concunit + ')')
                        self.lamunitlabel.insert('end', str(-(unitindex - 1)),
                                                 'super')
                    else:
                        self.lamunitlabel.insert('end', self.concunit + ' ')
                self.lamunitlabel.insert('end', self.timeunit)
                self.lamunitlabel.insert('end', '-1', 'super')
                self.lamunitlabel.tag_config('sub',
                                             offset=-4,
                                             font=self.subfont)
                self.lamunitlabel.tag_config('super',
                                             offset=5,
                                             font=self.superfont)
                self.lamunitlabel.tag_config('right', justify='right')
                self.lamunitlabel.config(state='disabled',
                                         background=self.bgcolor,
                                         borderwidth=0,
                                         spacing3=3)

                self.lamcoeflabel.grid(row=2,
                                       column=5,
                                       padx=2,
                                       sticky='WE',
                                       columnspan=4)

                self.ratewidget.grid(row=4, column=4, padx=5)
                self.lamcoefwidget.grid(row=4, column=5, padx=2, sticky='E')
                self.lamunitlabel.grid(row=4, column=6, padx=2, sticky='W')

        else:
            self.layerwidget = OptionMenu(self.frame,
                                          self.layer,
                                          *self.layer_list,
                                          command=self.click_layer)
            self.layerwidget.grid(row=4, column=1, padx=2, sticky='WE')
            self.click_layer()

        self.okbutton = Button(self.frame,
                               text='OK',
                               width=20,
                               command=self.OK)
        self.cancelbutton = Button(self.frame,
                                   text='Cancel',
                                   width=20,
                                   command=self.Cancel)
        self.blank2 = Label(self.frame, text=' ')
        self.blank3 = Label(self.frame, text=' ')
        self.blank4 = Label(self.frame, text=' ')
        self.focusbutton = None

        self.blank3.grid(row=5)
        self.okbutton.grid(row=6, columnspan=11)
        self.cancelbutton.grid(row=7, columnspan=11)
        self.blank4.grid(row=8)
        self.okbutton.bind('<Return>', self.OK)
        self.focusbutton = self.okbutton

    def click_layer(self, event=None):

        try:
            self.namewidget.grid_forget()
        except:
            pass

        self.reaction.set(self.reaction_list[self.layer_list.index(
            self.layer.get())][0])
        self.namewidget = OptionMenu(self.frame,
                                     self.reaction,
                                     *self.reaction_list[self.layer_list.index(
                                         self.layer.get())],
                                     command=self.click_reaction)
        self.namewidget.grid(row=4, column=2, padx=2, sticky='WE')

        self.click_reaction()

    def click_reaction(self, event=None):

        try:
            self.equationwidget.grid_forget()
            self.ratewidget.grid_forget()
        except:
            pass

        try:
            self.lamcoeflabel.grid_forget()
            self.lamcoefwidget.grid_forget()
            self.lamunitlabel.grid_forget()
        except:
            pass

        coefficient = self.coefficients[self.layer.get()][self.reaction.get()]
        self.lam.set(coefficient.lam)

        self.equation = coefficient.reaction.equation
        self.equationwidget = Label(self.frame,
                                    text=self.equation,
                                    font=self.formulatype)
        self.equationwidget.grid(row=4, column=3, padx=5)

        if coefficient.reaction.model == 'User-defined' or coefficient.reaction.model == 'Fundamental':

            unitindex = 0

            tkfont = tkFont.Font(font=self.formulatype)
            tksubfont = tkFont.Font(font=self.subfont)
            tksuperfont = tkFont.Font(font=self.superfont)

            # Measure the width of rate and lambda expression
            rate_len = tkfont.measure(u'r = \u03BB')
            rate_len = rate_len + tksubfont.measure(
                str(coefficient.reaction.number) + ',')
            if coefficient.layer.number == 0:
                rate_len = rate_len + tksubfont.measure('D')
            else:
                rate_len = rate_len + tksubfont.measure(
                    str(coefficient.layer.number))
            for reactant in coefficient.reaction.reactants:
                if reactant.index <> 0:
                    rate_len = rate_len + tkfont.measure('C')
                    rate_len = rate_len + tksubfont.measure(reactant.formula)
                    if reactant.index == int(reactant.index):
                        index = int(reactant.index)
                    else:
                        index = reactant.index

                    if index <> 1.:
                        rate_len = rate_len + tksuperfont.measure(
                            str(index) + ' ')
                    unitindex = unitindex + reactant.index

            lam_len = tkfont.measure('')
            if unitindex == int(unitindex): unitindex = int(unitindex)
            if (unitindex - 1) != 0:
                if (unitindex - 1) != 1:
                    lam_len = lam_len + tkfont.measure('(' + self.concunit +
                                                       ')')
                    lam_len = lam_len + tksuperfont.measure(
                        str(-(unitindex - 1)))
                else:
                    lam_len = lam_len + tkfont.measure(self.concunit)
            lam_len = lam_len + tkfont.measure(self.timeunit)
            lam_len = lam_len + tksuperfont.measure('-1')

            self.ratewidget = Text(self.frame,
                                   width=int(rate_len * 1.1424219345 / 8) + 1,
                                   height=1,
                                   font=self.formulatype)
            self.ratewidget.insert('end', u'r = \u03BB')
            self.ratewidget.insert('end',
                                   str(coefficient.reaction.number) + ',',
                                   'sub')
            if coefficient.layer.number == 0:
                self.ratewidget.insert('end', 'D', 'sub')
            else:
                self.ratewidget.insert('end', str(coefficient.layer.number),
                                       'sub')
            for reactant in coefficient.reaction.reactants:
                if reactant.index <> 0:
                    self.ratewidget.insert('end', 'C')
                    self.ratewidget.insert('end', reactant.formula, 'sub')
                    if reactant.index == int(reactant.index):
                        index = int(reactant.index)
                    else:
                        index = reactant.index
                    if index <> 1.:
                        self.ratewidget.insert('end',
                                               str(index) + ' ', 'super')

            self.ratewidget.tag_config('sub', offset=-4, font=self.subfont)
            self.ratewidget.tag_config('super', offset=5, font=self.superfont)
            self.ratewidget.tag_config('right', justify='right')
            self.ratewidget.config(state='disabled',
                                   background=self.bgcolor,
                                   borderwidth=0,
                                   spacing3=3)

            self.lamcoefwidget = Entry(self.frame,
                                       textvariable=self.lam,
                                       justify='center',
                                       width=8)

            self.lamunitlabel = Text(self.frame,
                                     width=int(lam_len * 1.1424219345 / 8) + 1,
                                     height=1,
                                     font=self.formulatype)
            if unitindex == int(unitindex): unitindex = int(unitindex)
            if (unitindex - 1) != 0:
                if (unitindex - 1) != 1:
                    self.lamunitlabel.insert('end', '(' + self.concunit + ')')
                    self.lamunitlabel.insert('end', str(-(unitindex - 1)),
                                             'super')
                else:
                    self.lamunitlabel.insert('end', self.concunit)
            self.lamunitlabel.insert('end', self.timeunit)
            self.lamunitlabel.insert('end', '-1', 'super')
            self.lamunitlabel.tag_config('sub', offset=-4, font=self.subfont)
            self.lamunitlabel.tag_config('super',
                                         offset=5,
                                         font=self.superfont)
            self.lamunitlabel.tag_config('right', justify='right')
            self.lamunitlabel.config(state='disabled',
                                     background=self.bgcolor,
                                     borderwidth=0,
                                     spacing3=3)

            self.lamcoeflabel.grid(row=2,
                                   column=5,
                                   padx=2,
                                   sticky='WE',
                                   columnspan=4)

            self.ratewidget.grid(row=4, column=4, padx=5)
            self.lamcoefwidget.grid(row=4, column=5, padx=2, sticky='E')
            self.lamunitlabel.grid(row=4, column=6, padx=2, sticky='W')

        self.frame.update()
        self.focusbutton = None
        self.master.geometry()
        self.master.center()

    def OK(self, event=None):
        """Finish and move on.  Checks that the number chemicals are less than the
        total number of chemicals in database."""

        if self.editflag == 0:
            self.layerindex = self.layer_full_list.index(self.layer.get())
            self.reactionnumber = self.reaction_full_list.index(
                self.reaction.get()) + 1

        if self.master.window.top is not None: self.master.open_toplevel()
        elif self.lam == 0: self.coefficient_error()
        else: self.master.tk.quit()

    def coefficient_error(self):

        tkmb.showerror(
            title=self.version,
            message='At least one chemical has been replicated in the reaction!'
        )
        self.focusbutton = self.okbutton
        self.master.tk.lift()

    def Cancel(self):

        try:
            self.reactants = self.reaction.reactants
            self.products = self.reaction.products

        except:
            self.cancelflag = 1

        if self.master.window.top is not None: self.master.open_toplevel()
        else: self.master.tk.quit()
Beispiel #49
0
#activity 3
from Tkinter import Tk, Label, Entry, Button, StringVar

my_app = Tk(className='Figure Of Geometry')

L1 = Label(my_app, text='Figure Of Geometry', font=('Arial', 24))
L1.grid(row=0, column=0)

L2 = Label(
    my_app,
    text='Sphare, dimensions three, examples: ball, meatball, and others')
L2.grid(row=1, column=0)

L3 = Label(my_app, text='Radius: ')
L3.grid(row=2, column=0)
str3 = StringVar()
E1 = Entry(my_app, textvariable=str1)
E1.grid(row=2, column=1)

L5 = Label(my_app, text='result = ')
L5.grid(row=3, column=0)
L6 = Label(my_app, text='0')
L6.grid(row=3, column=1)


def area():
    s = float(str1.get())
    result = 4 * 3.14 * (s * s)
    L6.config(text=result)

Beispiel #50
0
 def screen(self):
     self.sv = StringVar()
     self.sv.set(self.value)
     self.label = Label(frame, textvariable=self.sv, font=("arial", 40))
     self.label.grid(row=self.place, column=1)
     root.update()
Beispiel #51
0
def run():

    root = Tk()
    root.resizable(0, 0)

    def url_check(event):
        checked_url = url_format_correct(url_entry.get())
        if checked_url == 'URL correct':
            url_status.configure(text=checked_url, foreground='green')
            url_status.update()
            start_pysoar()
        else:
            url_status.configure(text=checked_url, foreground='red')
            url_status.update()

    def go_bugform(event):
        import webbrowser

        form_url = settings.debug_form_url
        versionID = settings.pysoar_version_formID
        urlID = settings.competition_url_formID
        pysoar_version = settings.version

        comp_url = url_entry.get()

        complete_url = '%s?entry.%s=%s&entry.%s=%s' % (form_url, versionID, pysoar_version, urlID, comp_url)
        webbrowser.open(complete_url)

    def start_pysoar():
        settings = Settings()
        soaring_spot_info = SoaringSpotImport()
        competition_day = CompetitionDay()

        soaring_spot_info.load(url_entry.get())

        for index in range(len(soaring_spot_info.file_urls)):
            while not os.path.exists(soaring_spot_info.igc_directory + "/" + soaring_spot_info.file_names[index]):
                soaring_spot_info.download_flight(index)
                time.sleep(0.1)
            soaring_spot_info.flights_downloaded += 1
            download_progress.configure(text='Downloaded: ' + str(soaring_spot_info.flights_downloaded) + '/' + str(len(soaring_spot_info.file_names)))
            download_progress.update()

        if settings.debugging:
            soaring_spot_info.save(settings)

        for ii in range(len(soaring_spot_info.file_names)):
            file_name = soaring_spot_info.file_names[ii]
            ranking = soaring_spot_info.rankings[ii]
            competition_day.file_paths.append(soaring_spot_info.igc_directory + file_name)
            competition_day.flights.append(Flight(file_name, ranking))
            competition_day.flights[-1].read_igc(competition_day, soaring_spot_info)

        competition_day.write_task()
        if competition_day.multi_start:
            url_status.configure(text="Multiple starting points not implemented!", foreground='red')
            url_status.update()
            return

        if settings.debugging:
            competition_day.save()

        for flight in competition_day.flights:

            print flight.file_name

            flight.determine_tsk_times(competition_day)
            flight.save(soaring_spot_info)

            flight.phases = FlightPhases(competition_day)
            flight.phases.determine_phases(settings, competition_day, flight)

            if settings.debugging:
                flight.phases.save(soaring_spot_info, flight)
            flight.phases.determine_point_statistics(flight, competition_day)

            flight.performance = Performance(competition_day, flight)
            flight.performance.determine_performance(flight, competition_day)

            soaring_spot_info.flights_analyzed += 1
            analysis_progress.configure(text='Analyzed: ' + str(soaring_spot_info.flights_analyzed) + '/' + str(len(soaring_spot_info.file_names)))
            analysis_progress.update()

        excel_sheet = ExcelExport(settings, competition_day)
        excel_sheet.write_file(competition_day, settings, soaring_spot_info)

        analysis_done = Button(root, text='Excel produced', command=open_analysis_file)
        analysis_done.grid(row=6, column=0, pady=5)
        print "Analysis complete, excel produced"

    title = Label(root, text=' PySoar', font=("Helvetica", 30))
    url_accompanying_text = Label(root, text='Give Soaringspot URL:')
    url_entry = Entry(root, width=60)
    url_confirmation = Button(root, text='ok')
    url_confirmation.bind('<Button-1>', url_check)
    url_status = Label(root, text='', foreground='red')
    download_progress = Label(root, text='Downloaded: ')
    analysis_progress = Label(root, text='Analyzed: ')
    report_problem = Button(root, text='Report problem')
    report_problem.bind('<Button-1>', go_bugform)
    root.bind('<Return>', url_check)
    version = Label(root, text='v %s' % settings.version)

    title.grid(row=0, column=0)
    url_accompanying_text.grid(row=1, column=0, sticky=W)
    url_entry.grid(row=2, column=0)
    url_confirmation.grid(row=2, column=1)
    url_status.grid(row=3, column=0)
    download_progress.grid(row=4, column=0, pady=5)
    analysis_progress.grid(row=5, column=0, pady=5)
    report_problem.grid(row=7, column=0, sticky=W)
    version.grid(row=7, column=1, sticky=E)

    root.mainloop()
Beispiel #52
0
l0 = StringVar()
l0.set('Licht')
z0 = StringVar()
z0.set('Zuurstof')
#column 1
t2 = StringVar()
v2 = StringVar()
l2 = StringVar()
z2 = StringVar()

t2.set(T)
v2.set(V)
l2.set(L)
z2.set(Z)

labelt = Label(frame, textvariable=t0, font=("arial", 40))
labelt.grid(row=0, column=0)
labelv = Label(frame, textvariable=v0, font=("arial", 40))
labelv.grid(row=1, column=0)
labell = Label(frame, textvariable=l0, font=("arial", 40))
labell.grid(row=2, column=0)
labelz = Label(frame, textvariable=z0, font=("arial", 40))
labelz.grid(row=3, column=0)
t3 = StringVar()
t3.set('°C')
v3 = StringVar()
v3.set('%')
l3 = StringVar()
l3.set('lux')
z3 = StringVar()
z3.set('ppm')
Beispiel #53
0
class GUI:
    def __init__(self,
                 model,
                 title='PyCX Simulator',
                 interval=0,
                 stepSize=1,
                 param_gui_names=None):
        self.model = model
        self.titleText = title
        self.timeInterval = interval
        self.stepSize = stepSize
        self.param_gui_names = param_gui_names
        if param_gui_names is None:
            self.param_gui_names = {}
        self.param_entries = {}
        self.statusStr = ""
        self.running = False
        self.modelFigure = None
        self.currentStep = 0

        self.initGUI()

    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr)
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW', self.quitGUI)
        self.rootWindow.geometry('550x700')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)

        self.frameSim = Frame(self.rootWindow)

        self.frameSim.pack(expand=YES, fill=BOTH, padx=5, pady=5, side=TOP)
        self.status = Label(self.rootWindow,
                            width=40,
                            height=3,
                            relief=SUNKEN,
                            bd=1,
                            textvariable=self.statusText)
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)

        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameSim,
                                width=30,
                                height=2,
                                textvariable=self.runPauseString,
                                command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)

        self.showHelp(
            self.buttonRun,
            "Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameSim,
                                 width=30,
                                 height=2,
                                 text="Step Once",
                                 command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep, "Steps the simulation only once")
        self.buttonReset = Button(self.frameSim,
                                  width=30,
                                  height=2,
                                  text="Reset",
                                  command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonReset, "Resets the simulation")

        for param in self.model.params:
            var_text = self.param_gui_names.get(param, param)
            can = Canvas(self.frameSim)
            lab = Label(can,
                        width=25,
                        height=1 + var_text.count('\n'),
                        text=var_text,
                        anchor=W,
                        takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            val = getattr(self.model, param)
            if isinstance(val, bool):
                val = int(val)  # Show 0/1 which can convert back to bool
            ent.insert(0, str(val))
            ent.pack(side='left')
            can.pack(side='top')
            self.param_entries[param] = ent
        if self.param_entries:
            self.buttonSaveParameters = Button(
                self.frameSim,
                width=50,
                height=1,
                command=self.saveParametersCmd,
                text="Save parameters to the running model",
                state=DISABLED)
            self.showHelp(
                self.buttonSaveParameters, "Saves the parameter values.\n" +
                "Not all values may take effect on a running model\n" +
                "A model reset might be required.")
            self.buttonSaveParameters.pack(side='top', padx=5, pady=5)
            self.buttonSaveParametersAndReset = Button(
                self.frameSim,
                width=50,
                height=1,
                command=self.saveParametersAndResetCmd,
                text="Save parameters to the model and reset the model")
            self.showHelp(
                self.buttonSaveParametersAndReset,
                "Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top', padx=5, pady=5)

        can = Canvas(self.frameSim)
        lab = Label(can,
                    width=25,
                    height=1,
                    text="Step size ",
                    justify=LEFT,
                    anchor=W,
                    takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,
                               from_=1,
                               to=500,
                               resolution=1,
                               command=self.changeStepSize,
                               orient=HORIZONTAL,
                               width=25,
                               length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(
            self.stepScale,
            "Skips model redraw during every [n] simulation steps\n" +
            "Results in a faster model run.")
        self.stepScale.pack(side='left')
        can.pack(side='top')

        can = Canvas(self.frameSim)
        lab = Label(can,
                    width=25,
                    height=1,
                    text="Step visualization delay in ms ",
                    justify=LEFT,
                    anchor=W,
                    takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,
                               from_=0,
                               to=max(2000, self.timeInterval),
                               resolution=10,
                               command=self.changeStepDelay,
                               orient=HORIZONTAL,
                               width=25,
                               length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(
            self.stepDelay, "The visualization of each step is " +
            "delays by the given number of " + "milliseconds.")
        self.stepDelay.pack(side='left')
        can.pack(side='top')

    def setStatusStr(self, newStatus):
        self.statusStr = newStatus
        self.statusText.set(self.statusStr)

    #model control functions
    def changeStepSize(self, val):
        self.stepSize = int(val)

    def changeStepDelay(self, val):
        self.timeInterval = int(val)

    def saveParametersCmd(self):
        for param, entry in self.param_entries.items():
            val = entry.get()
            if isinstance(getattr(self.model, param), bool):
                val = bool(int(val))
            setattr(self.model, param, val)
            # See if the model changed the value (e.g. clipping)
            new_val = getattr(self.model, param)
            if isinstance(new_val, bool):
                new_val = int(new_val)
            entry.delete(0, END)
            entry.insert(0, str(new_val))
        self.setStatusStr("New parameter values have been set")

    def saveParametersAndResetCmd(self):
        self.saveParametersCmd()
        self.resetModel()

    def runEvent(self):
        if not self.running:
            self.running = True
            self.rootWindow.after(self.timeInterval, self.stepModel)
            self.runPauseString.set("Pause")
            self.buttonStep.configure(state=DISABLED)
            if self.param_entries:
                self.buttonSaveParameters.configure(state=NORMAL)
                self.buttonSaveParametersAndReset.configure(state=DISABLED)
        else:
            self.stopRunning()

    def stopRunning(self):
        self.running = False
        self.runPauseString.set("Continue Run")
        self.buttonStep.configure(state=NORMAL)
        self.drawModel()
        if self.param_entries:
            self.buttonSaveParameters.configure(state=NORMAL)
            self.buttonSaveParametersAndReset.configure(state=NORMAL)

    def stepModel(self):
        if self.running:
            if self.model.step() is True:
                self.stopRunning()
            self.currentStep += 1
            self.setStatusStr("Step " + str(self.currentStep))
            self.status.configure(foreground='black')
            if (self.currentStep) % self.stepSize == 0:
                self.drawModel()
            self.rootWindow.after(int(self.timeInterval * 1.0 / self.stepSize),
                                  self.stepModel)

    def stepOnce(self):
        self.running = False
        self.runPauseString.set("Continue Run")
        self.model.step()
        self.currentStep += 1
        self.setStatusStr("Step " + str(self.currentStep))
        self.drawModel()
        if self.param_entries:
            self.buttonSaveParameters.configure(state=NORMAL)

    def resetModel(self):
        self.running = False
        self.runPauseString.set("Run")
        self.model.reset()
        self.currentStep = 0
        self.setStatusStr("Model has been reset")
        self.drawModel()

    def drawModel(self):
        if self.modelFigure is None:
            self.modelFigure = plt.figure()
            plt.ion()
            # plt.show() will cause the plot to be actually displayed
            plt.show()
        self.model.draw()

        # Tell matplotlib to redraw too. The darwin-version works with more
        # types of matplotlib backends, but seems to fail on some Linux
        # machines. Hence we use the TkAgg specific method when available.

        if sys.platform == 'darwin':
            self.modelFigure.canvas.manager.show()
        else:
            self.modelFigure.canvas.manager.window.update()

    def start(self):
        if self.model.step.__doc__:
            self.showHelp(self.buttonStep, self.model.step.__doc__.strip())

        self.model.reset()
        self.drawModel()
        self.rootWindow.mainloop()

    def quitGUI(self):
        plt.close('all')
        self.rootWindow.quit()
        self.rootWindow.destroy()

    def showHelp(self, widget, text):
        def setText(self):
            self.statusText.set(text)
            self.status.configure(foreground='blue')

        def showHelpLeave(self):
            self.statusText.set(self.statusStr)
            self.status.configure(foreground='black')

        widget.bind("<Enter>", lambda e: setText(self))
        widget.bind("<Leave>", lambda e: showHelpLeave(self))
Beispiel #54
0
 def __init__(self, parent):
     top = self.top = Toplevel(parent)
     Label(top, text=msg).pack()
     b = Button(top, text="OK", command=self.ok)
     b.pack(pady=5)
def falseType(falseb,auxVariable,Labelt,Labeli,img0,imgF):
    
    if falseb:
        Labeli=Label(ventana2,image=img0)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text='Cumplió con el tiempo requerido')
        ventana2.update()
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), now(), 'cumplio con el tiempo en jabon')")
##        Labeli.config(image=img0)
##        Labeli.image=img0()
        time.sleep(2)
        return True
        
        
    elif auxVariable == 2:
        Labeli=Label(ventana2,image=imgF)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text="No se detectó movimiento de sus manos \n Vuelva a empezar")
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), now(), 'No hubo suficiente movimiento de las manos')")
        ventana2.update()
        time.sleep(2)
        return False

        
    elif auxVariable == 3:
        Labeli=Label(ventana2,image=imgF)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text="No se detectaron sus manos \n Vuelva a empezar")
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), now(), 'No se detectaron las manos')")
        ventana2.update()
        time.sleep(2)
        return False
        

    elif auxVariable == 4:
        Labeli=Label(ventana2,image=imgF)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text="No se detectaron sus manos dentro de la región de lectura \n Vuelva a empezar")
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), now(), ' No se registraron manos dentro de la region')")
        ventana2.update()
        time.sleep(2)
        return False      
Beispiel #56
0
    def initGUI(self):
        #create root window
        self.rootWindow = Tk()
        self.statusText = StringVar(value=self.statusStr)
        self.setStatusStr("Simulation not yet started")

        self.rootWindow.wm_title(self.titleText)
        self.rootWindow.protocol('WM_DELETE_WINDOW', self.quitGUI)
        self.rootWindow.geometry('550x700')
        self.rootWindow.columnconfigure(0, weight=1)
        self.rootWindow.rowconfigure(0, weight=1)

        self.frameSim = Frame(self.rootWindow)

        self.frameSim.pack(expand=YES, fill=BOTH, padx=5, pady=5, side=TOP)
        self.status = Label(self.rootWindow,
                            width=40,
                            height=3,
                            relief=SUNKEN,
                            bd=1,
                            textvariable=self.statusText)
        self.status.pack(side=TOP, fill=X, padx=1, pady=1, expand=NO)

        self.runPauseString = StringVar()
        self.runPauseString.set("Run")
        self.buttonRun = Button(self.frameSim,
                                width=30,
                                height=2,
                                textvariable=self.runPauseString,
                                command=self.runEvent)
        self.buttonRun.pack(side=TOP, padx=5, pady=5)

        self.showHelp(
            self.buttonRun,
            "Runs the simulation (or pauses the running simulation)")
        self.buttonStep = Button(self.frameSim,
                                 width=30,
                                 height=2,
                                 text="Step Once",
                                 command=self.stepOnce)
        self.buttonStep.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonStep, "Steps the simulation only once")
        self.buttonReset = Button(self.frameSim,
                                  width=30,
                                  height=2,
                                  text="Reset",
                                  command=self.resetModel)
        self.buttonReset.pack(side=TOP, padx=5, pady=5)
        self.showHelp(self.buttonReset, "Resets the simulation")

        for param in self.model.params:
            var_text = self.param_gui_names.get(param, param)
            can = Canvas(self.frameSim)
            lab = Label(can,
                        width=25,
                        height=1 + var_text.count('\n'),
                        text=var_text,
                        anchor=W,
                        takefocus=0)
            lab.pack(side='left')
            ent = Entry(can, width=11)
            val = getattr(self.model, param)
            if isinstance(val, bool):
                val = int(val)  # Show 0/1 which can convert back to bool
            ent.insert(0, str(val))
            ent.pack(side='left')
            can.pack(side='top')
            self.param_entries[param] = ent
        if self.param_entries:
            self.buttonSaveParameters = Button(
                self.frameSim,
                width=50,
                height=1,
                command=self.saveParametersCmd,
                text="Save parameters to the running model",
                state=DISABLED)
            self.showHelp(
                self.buttonSaveParameters, "Saves the parameter values.\n" +
                "Not all values may take effect on a running model\n" +
                "A model reset might be required.")
            self.buttonSaveParameters.pack(side='top', padx=5, pady=5)
            self.buttonSaveParametersAndReset = Button(
                self.frameSim,
                width=50,
                height=1,
                command=self.saveParametersAndResetCmd,
                text="Save parameters to the model and reset the model")
            self.showHelp(
                self.buttonSaveParametersAndReset,
                "Saves the given parameter values and resets the model")
            self.buttonSaveParametersAndReset.pack(side='top', padx=5, pady=5)

        can = Canvas(self.frameSim)
        lab = Label(can,
                    width=25,
                    height=1,
                    text="Step size ",
                    justify=LEFT,
                    anchor=W,
                    takefocus=0)
        lab.pack(side='left')
        self.stepScale = Scale(can,
                               from_=1,
                               to=500,
                               resolution=1,
                               command=self.changeStepSize,
                               orient=HORIZONTAL,
                               width=25,
                               length=150)
        self.stepScale.set(self.stepSize)
        self.showHelp(
            self.stepScale,
            "Skips model redraw during every [n] simulation steps\n" +
            "Results in a faster model run.")
        self.stepScale.pack(side='left')
        can.pack(side='top')

        can = Canvas(self.frameSim)
        lab = Label(can,
                    width=25,
                    height=1,
                    text="Step visualization delay in ms ",
                    justify=LEFT,
                    anchor=W,
                    takefocus=0)
        lab.pack(side='left')
        self.stepDelay = Scale(can,
                               from_=0,
                               to=max(2000, self.timeInterval),
                               resolution=10,
                               command=self.changeStepDelay,
                               orient=HORIZONTAL,
                               width=25,
                               length=150)
        self.stepDelay.set(self.timeInterval)
        self.showHelp(
            self.stepDelay, "The visualization of each step is " +
            "delays by the given number of " + "milliseconds.")
        self.stepDelay.pack(side='left')
        can.pack(side='top')
Beispiel #57
0
    def setup_gui(self):
        # set up the gui

        # root is the Tkinter root widget
        self.root.title("Remote Monitor for Pi Presents")

        # self.root.configure(background='grey')

        self.root.resizable(False, False)

        # define response to main window closing
        self.root.protocol("WM_DELETE_WINDOW", self.app_exit)

        # bind some display fields
        self.desc = StringVar()
        self.filename = StringVar()
        self.display_show = StringVar()
        self.results = StringVar()
        self.status = StringVar()

        # define menu
        menubar = Menu(self.root)

        osc_configmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
        menubar.add_cascade(label='Options', menu=osc_configmenu)
        osc_configmenu.add_command(label='Edit', command=self.e_edit_osc)

        helpmenu = Menu(menubar, tearoff=0, bg="grey", fg="black")
        menubar.add_cascade(label='Help', menu=helpmenu)
        helpmenu.add_command(label='Help', command=self.show_help)
        helpmenu.add_command(label='About', command=self.about)

        self.root.config(menu=menubar)

        # info frame
        info_frame = Frame(self.root, padx=5, pady=5)
        info_frame.pack(side=TOP, fill=BOTH, expand=1)
        info_name = Label(info_frame,
                          text="Slave Unit's Name: " +
                          self.osc_config.this_unit_name,
                          font="arial 12 bold")
        info_name.pack(side=TOP)
        info_this_address = Label(info_frame,
                                  textvariable=self.desc,
                                  font="arial 12 bold")
        info_this_address.pack(side=TOP)

        # status_frame
        status_frame = Frame(self.root, padx=5, pady=5)
        status_frame.pack(side=TOP, fill=BOTH, expand=1)
        status_label = Label(status_frame,
                             text="Status:",
                             font="arial 12 bold")
        status_label.pack(side=LEFT)
        scrollbar = Scrollbar(status_frame, orient=VERTICAL)
        self.status_display = Text(status_frame,
                                   height=20,
                                   yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.status_display.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.status_display.pack(side=LEFT, fill=BOTH, expand=1)
def inicio(c):
    global ventana2, Labeli, Labelt, panel
    global img0, img1, imgF
    img0=PhotoImage(file="00.gif") # Reads photos
    img1=PhotoImage(file="11.gif")
    imgF=PhotoImage(file="FF.gif")
    
    if c:  
        ventana2=Toplevel(ventana)
        ventana2.title("MANITOR")
        ventana2.configure(bg="white")
        ventana2.geometry("1000x600+5+40")
    
        Labelt=Label(ventana2,text='BIENVENIDO ', # ventana2 TEXTO
                fg="black",bg="white",font=("Helvetica 36 "))
        ventana2.columnconfigure(0,weight=1)
        Labelt.grid(row=1,column=0)
        
        Labeli=Label(ventana2,image=img1) # ventana2 IMAGEN
        ventana2.columnconfigure(0,weight=1)
        ventana2.update()
        Labeli.grid(row=2,column=0)
        
    else:#Toda esta parte no es necesaria se podria borrar hasta el update, ya que es un estado inical que nunca se muestra igual que arriba
        Labelt.config(text='BIENVENIDO ')
        ventana2.update()
        Labeli=Label(ventana2,image=img1)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        Labeli.config(image=img1)
        Labeli.image=img1
        ventana2.update()
    ventana.iconify() # Turns window into an icon

    while 1:

##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' inicio ')")
        Labeli.destroy()
        ventana2.update()
        Labelt.config(text='BIENVENIDO \n  Por favor moje sus manos con agua')
        ventana2.update()
        video000                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ()
        ventana2.update()
        
        Labelt.config(text='Deposite jabón en la mano')
##        cur.execute("INSERT INTO manitor VALUES(nextval('usuario_sequence'), current_timestamp, ' nuevo usuario ')")
        ventana2.update()

        def cero():
            b,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) 
            instruction = falseType(b,auxType,Labelt,Labeli,img0,imgF)
            if not instruction:
                inicio(0)
                
        Thread(target=cero).start()
        Thread(target=video00()).start()

######################## instruccion 1
        
        Labeli.destroy()
        Labelt.config(text='Frote las palmas de las manos \n entre sí')
        ventana2.update()

        def primero():
            d,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],3,2,lower,upper) 
            instruction = falseType(d,auxType,Labelt,Labeli,img0,imgF)
            if not instruction:
                inicio(0)
                
        Thread(target=primero).start()
        Thread(target=video1()).start()

########################## instruccion2
##
##        Labeli.destroy()
##        Labelt.config(text='Frote la palma de la mano derecha \n contra el dorso de la mano izquierda  \n entrelazando los dedos y viceversa')
##        panel = Label(ventana2)

##        def segundo():
##            e,auxType = contadorMovimiento.funcionMovimientoEnRegion(y[1],10,2,lower,upper) 
##            instruction = falseType(e,auxType,Labelt,Labeli,img0,imgF)
##            if not instruction:
##                inicio(0)
##                
##        Thread(target=segundo).start()
##        Thread(target=video1()).start()
##        
##        time.sleep(10)

######################## fin instrucciones
##
        Labeli=Label(ventana2,image=img12)
        ventana2.columnconfigure(0,weight=1)
        Labeli.grid(row=2,column=0)
        ventana2.update()
        Labelt.config(text='Sus manos son seguras')
##        Labeli.config(image=img12)
##        Labeli.image=img12
        ventana2.update()
        time.sleep(5)
    def setUI(self):
        self.parent.title("ServoGui")
        self.pack(fill=BOTH, expand=1)
        self.comPort = StringVar(self)
        self.laststrm = StringVar(self)

        settingFrame = Frame(self, borderwidth=1, relief=RAISED)
        settingFrame.pack(fill=Y, side=LEFT)

        Label(settingFrame, width=50, text="Port Settings", bg="green", fg="black").pack(fill=X)

        ports = self.getComPorts()
        w = apply(OptionMenu, (settingFrame, self.comPort) + tuple(ports))
        w.pack(fill=X)

        BaudFrame = Frame(settingFrame)
        BaudFrame.pack(fill=X)
        Label(BaudFrame, text="Baud:").pack(side=LEFT)
        self.baud_entry = Entry(BaudFrame,
                                width=15,
                                validate="focusout",
                                validatecommand=self.baudValidate)
        self.baud_entry.pack(side=LEFT, expand=True)
        self.baud_entry.insert(0, "115200")

        Button(settingFrame, text="Open Port", command=self.openPort). pack(fill=X)
        Button(settingFrame, text="Close Port", command=self.closePort). pack(fill=X)

        StreamFrame = Frame(settingFrame)
        StreamFrame.pack()
        self.btnStartStream = Button(StreamFrame,
                                text="Start Stream",
                                command=self.startStream,
                                state=DISABLED)
        self.btnStopStream = Button(StreamFrame,
                                text="Stop Stream",
                                command=self.stopStream,
                                state=DISABLED)
        self.btnGetConfig = Button(StreamFrame,
                                text="Get Config",
                                command=self.getConfig,
                                state=DISABLED)
        self.btnStartStream.pack(side=LEFT)
        self.btnStopStream.pack(side=LEFT)
        self.btnGetConfig.pack(side=LEFT)
        self.queue = Queue.Queue()
        self.writequeue = Queue.Queue()

        Label(settingFrame, width=50, text="Drive Settings", bg="green", fg="black").pack(fill=X)
        DriveSettingsFrame = Frame(settingFrame, relief=SUNKEN)
        DriveSettingsFrame.pack(fill=X)

        driveSettingsFrames = []
        self.driveSettingsEntries = []
        for drivesetting in drivesettings:
            driveSettingsFrames.append(Frame(DriveSettingsFrame))
            driveSettingsFrames[-1].pack(fill=X)
            Label(driveSettingsFrames[-1], text=drivesetting).pack(side=LEFT)
            self.driveSettingsEntries.append(Entry(driveSettingsFrames[-1]))
            self.driveSettingsEntries[-1].pack(side=RIGHT)
        Button(DriveSettingsFrame, text="Send to drive", command=self.sendConfig).pack(fill=X)
        Button(DriveSettingsFrame, text="Save config in drive", command=self.saveConfig).pack(fill=X)

        Label(settingFrame, width=50, textvariable=self.laststrm, bg="green", fg="black").pack(fill=X)

        # MatplotLib stuff

        f = Figure(figsize=(5, 4), dpi=100)
        self.a = f.add_subplot(411)
        self.a.set_title("Requested and actual position")
        self.b = f.add_subplot(412)
        self.b.set_title("Error")
        self.c = f.add_subplot(413)
        self.c.set_title("Current meas ADC value")
        self.d = f.add_subplot(414)
        self.d.set_title("HALL")
        self.canvas = FigureCanvasTkAgg(f, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)

        toolbar = NavigationToolbar2TkAgg(self.canvas, self)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

        self.hall = []
        self.encoder_count = []
        self.pos_error = []
        self.requested_position = []
        self.requested_delta = []
        self.adc_value = []
        self.pid_output = []
        self.a.set_autoscaley_on(True)

        self.encoder_line, = self.a.plot([], [])
        self.error_line, = self.d.plot([], [])
        self.reqpos_line, = self.a.plot([], [])
        self.ADC_line, = self.c.plot([], [])
        self.hall_line, = self.d.plot([], [])
        self.pwm_line, = self.b.plot([], [])
        self.updateCanvas()
##con = psycopg2.connect("dbname='prueba1' user='******' password='******'")
##cur = con.cursor()
##cur.execute("CREATE TABLE manitor(Id SERIAL PRIMARY KEY, fecha_hora TIMESTAMP default now(), calificacion VARCHAR(200))")
##cur.execute("CREATE SEQUENCE usuario_sequence start 1 increment 1")
##cur.execute("SET TIME ZONE 'GMT+5'")

######################## INTERFAZ GRAFICA 

ventana = Tk() # Initializes interpreter and creates root window
ventana.title('HELLO MANITOR') # Name of the window
ventana.configure(bg="white") # Background color
ventana.geometry("400x330+100+100") # Size of the window
ventana2= None 
Labelt=None
label=Label(ventana,text="BIENVENIDO",
             fg="red",bg="white",font=("Helvetica 24 bold"))
label.grid(row=1,column=1)

######################## LABEL REGIONES + FUNC REGIONES + BOTON REGIONES

labelregiones=Label(ventana,
             text="Por favor seleccione las regiones correspondientes",
             fg="black",bg="white",font=("Helvetica 12"))
labelregiones.grid(row=2,column=1)

def regiones():
    global y
    y = regions.funcionRegiones(2)
    #print y
    
botonregiones = Button(ventana,text="REGIONES", command=regiones,