Ejemplo n.º 1
2
    def __init__(self, parent, name="X", color="red"):
        """
        Description :
          Calcul d'une vibration harmonique du type : e=a*sin(2*pi*f*t+p)
        Proprietes :
          -  un parent (classe Oscilloscope)
          -  controleurs d'amplitude, frequence, phase (classe Scale)
        Methodes :
          - update_vibration(self, event) : callback si modification de controleurs
          - compute(self,a,f,p) : calcul de vibration harmonique
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.name = name
        self.scale_A = Scale(self, length=300, orient="horizontal",
                label=name + " Amplitude", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_vibration)

        self.scale_P = Scale(self, length=300, orient="horizontal",
                label=name + " Phase", showvalue=1, from_=0, to=90,
                tickinterval=20, command=self.update_vibration)

        self.scale_F = Scale(self, length=300, orient="horizontal",
                label=name + " Fréquence", showvalue=1, from_=0, to=100,
                tickinterval=10, command=self.update_vibration)

        self.scale_A.pack(expand="yes", fill="both")
        self.scale_P.pack(expand="yes", fill="both")
        self.scale_F.pack(expand="yes", fill="both")
    def __init__(self, parent, *args, **kw):
        Frame.__init__(self, parent, *args, **kw)
        vscrollbar = Scrollbar(self, orient=VERTICAL)
        vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
        canvas = Canvas(
            self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set)
        canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
        vscrollbar.config(command=canvas.yview)
        canvas.xview_moveto(0)
        canvas.yview_moveto(0)
        self.interior = interior = Frame(canvas)
        interior_id = canvas.create_window(0, 0, window=interior, anchor=NW)
        self.canv = canvas  # @UndefinedVariable
        self.scroller = vscrollbar

        def _configure_interior(event):
            size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
            canvas.config(scrollregion="0 0 %s %s" % size)
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.config(width=interior.winfo_reqwidth())
        interior.bind('<Configure>', _configure_interior)

        def _configure_canvas(event):
            if interior.winfo_reqwidth() != canvas.winfo_width():
                canvas.itemconfigure(interior_id, width=canvas.winfo_width())
        canvas.bind('<Configure>', _configure_canvas)
Ejemplo n.º 3
0
    def __init__( self, parent, net, node, height=10, width=32, title='Node' ):
        Frame.__init__( self, parent )

        self.net = net
        self.node = node
        self.prompt = node.name + '# '
        self.height, self.width, self.title = height, width, title

        # Initialize widget styles
        self.buttonStyle = { 'font': 'Monaco 7' }
        self.textStyle = {
            'font': 'Monaco 7',
            'bg': 'black',
            'fg': 'green',
            'width': self.width,
            'height': self.height,
            'relief': 'sunken',
            'insertbackground': 'green',
            'highlightcolor': 'green',
            'selectforeground': 'black',
            'selectbackground': 'green'
        }

        # Set up widgets
        self.text = self.makeWidgets( )
        self.bindEvents()
        self.sendCmd( 'export TERM=dumb' )

        self.outputHook = None
Ejemplo n.º 4
0
    def __init__(self, parent):

        # IMAGES #########
        self.NODE_IMG = [
            ImageTk.PhotoImage(Image.open("img/node1.png")),
            ImageTk.PhotoImage(Image.open("img/node2.png")),
            ImageTk.PhotoImage(Image.open("img/node3.png")),
            ImageTk.PhotoImage(Image.open("img/node4.png")),
        ]

        self.BG = ImageTk.PhotoImage(Image.open("img/map.png"))

        self.FLAG_AXIS = ImageTk.PhotoImage(Image.open("img/flag_axis.png"))
        self.FLAG_ALLY = ImageTk.PhotoImage(Image.open("img/flag_ally.png"))

        self.CANNON = ImageTk.PhotoImage(Image.open("img/cannon.png"))
        self.FORTRESS = ImageTk.PhotoImage(Image.open("img/fort.png"))
        #################

        Frame.__init__(self, parent)

        self.parent = parent
        self.init_ui()
        self.update_ui()
        self.update_menu()
Ejemplo n.º 5
0
Archivo: ui.py Proyecto: mindhog/mawb
    def __init__(self, top, commands):
        Frame.__init__(self, top)
        self.text = Text(self)
        self.text.grid()

        commands.window = self
        self.bind('<<channel-change>>', self.__onChannelChange)
        self.bind('<<program-change>>', self.__onProgramChange)

        self.buttons = Frame(self)
        self.playBtn = Button(self.buttons, text = '>',
                              command = commands.togglePlay
                              )
        self.playBtn.pack(side = LEFT)
        self.buttons.grid(sticky = W)

        self.status = Frame(self)
        self.status.channelLbl, self.status.channelTxt = \
            makeROEntry(self.status, 0, 0, 'Channel:', '0')
        self.status.programLbl, self.status.programTxt = \
            makeROEntry(self.status, 0, 2, 'Program:', getProgramName(0))
        self.status.grid(sticky = W)

        commands.out = Output(self.text)
        self.bindCommands(commands)
        self.commands = commands
        self.grid()
Ejemplo n.º 6
0
    def __init__( self, net, parent=None, width=4 ):
        Frame.__init__( self, parent )
        self.top = self.winfo_toplevel()
        self.top.title( 'Mininet' )
        self.net = net
        self.menubar = self.createMenuBar()
        cframe = self.cframe = Frame( self )
        self.consoles = {}  # consoles themselves
        titles = {
            'hosts': 'Host',
            'switches': 'Switch',
            'controllers': 'Controller'
        }
        for name in titles:
            nodes = getattr( net, name )
            frame, consoles = self.createConsoles(
                cframe, nodes, width, titles[ name ] )
            self.consoles[ name ] = Object( frame=frame, consoles=consoles )
        self.selected = None
        self.select( 'hosts' )
        self.cframe.pack( expand=True, fill='both' )
        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol( self.top, name='WM_DELETE_WINDOW', func=self.quit )

        # Initialize graph
        graph = Graph( cframe )
        self.consoles[ 'graph' ] = Object( frame=graph, consoles=[ graph ] )
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len( self.consoles[ 'hosts' ].consoles )
        self.bw = 0

        self.pack( expand=True, fill='both' )
Ejemplo n.º 7
0
    def __init__(self, net, parent=None, width=4):
        Frame.__init__(self, parent)
        self.top = self.winfo_toplevel()
        self.top.title("Mininet")
        self.net = net
        self.menubar = self.createMenuBar()
        cframe = self.cframe = Frame(self)
        self.consoles = {}  # consoles themselves
        titles = {"hosts": "Host", "switches": "Switch", "controllers": "Controller"}
        for name in titles:
            nodes = getattr(net, name)
            frame, consoles = self.createConsoles(cframe, nodes, width, titles[name])
            self.consoles[name] = Object(frame=frame, consoles=consoles)
        self.selected = None
        self.select("hosts")
        self.cframe.pack(expand=True, fill="both")
        cleanUpScreens()
        # Close window gracefully
        Wm.wm_protocol(self.top, name="WM_DELETE_WINDOW", func=self.quit)

        # Initialize graph
        graph = Graph(cframe)
        self.consoles["graph"] = Object(frame=graph, consoles=[graph])
        self.graph = graph
        self.graphVisible = False
        self.updates = 0
        self.hostCount = len(self.consoles["hosts"].consoles)
        self.bw = 0

        self.pack(expand=True, fill="both")
Ejemplo n.º 8
0
    def __init__(self, parent, net, node, height=10, width=32, title="Node"):
        Frame.__init__(self, parent)

        self.net = net
        self.node = node
        self.prompt = node.name + "# "
        self.height, self.width, self.title = height, width, title

        # Initialize widget styles
        self.buttonStyle = {"font": "Monaco 7"}
        self.textStyle = {
            "font": "Monaco 7",
            "bg": "black",
            "fg": "green",
            "width": self.width,
            "height": self.height,
            "relief": "sunken",
            "insertbackground": "green",
            "highlightcolor": "green",
            "selectforeground": "black",
            "selectbackground": "green",
        }

        # Set up widgets
        self.text = self.makeWidgets()
        self.bindEvents()
        self.sendCmd("export TERM=dumb")

        self.outputHook = None
Ejemplo n.º 9
0
    def __init__(self, root, *args, **kwargs):
        Frame.__init__(self, root, *args, **kwargs)

        self.app = root
        self.app.title('Campus TOur Guide v1.0')
        self.app.wm_iconbitmap('tour.ico')
        self.app.resizable(width=False, height=False)



        # the container is where we'll stack a bunch of frames
        # on top of each other, then the one we want visible
        # will be raised above the others
        container = Frame(root)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (StartPage, Instructions,Selection):
            frame = F(container, self)
            self.frames[F] = frame
            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")
        self.show_frame(StartPage)
Ejemplo n.º 10
0
    def __init__(self, parent, name="X"):
        """
        Initialisation

        parent : un oscilloscope
        name : nom du signal
        """
        Frame.__init__(self)
        self.configure(bd=1, relief="sunken")
        self.parent = parent
        self.name = name
        self.drawVar = IntVar()
        self.signal = None

        self.draw = Checkbutton(self,text="Afficher "+self.name, selectcolor=eval('self.parent.view.color_'+name), variable=self.drawVar, onvalue = 1, offvalue = 0, command=self.parent.plot_all)
        self.draw.pack()
        self.draw.select()

        self.scale_A = Scale(self, length=100, orient="horizontal",
                label=name + " Amplitude", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_signal)
        self.scale_A.pack(expand="yes", fill="both")

        self.scale_F = Scale(self, length=100, orient="horizontal",
                label=name + " Fréquence", showvalue=1, from_=1, to=10,
                tickinterval=1, command=self.update_signal)
        self.scale_F.pack(expand="yes", fill="both")

        self.scale_P = Scale(self, length=100, orient="horizontal",
                label=name + " Phase", showvalue=1, from_=0, to=10,
                tickinterval=1, command=self.update_signal)
        self.scale_P.pack(expand="yes", fill="both")

        
        self.bind("<Configure>",self.update_signal)
Ejemplo n.º 11
0
 def __init__(self, master=None, title='', items=(('客户名称',36),('机构类型',10),('国别', 10),('营业执照编号',20),('注册资本',10)), next_func=None):
     Frame.__init__(self, master, relief=Tkinter.GROOVE )
     self.mutilistbox_items = items
     self.next_func = next_func
     self.next_func_button = None
     self.title = title
     self.create_widget()
Ejemplo n.º 12
0
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")
        self.parent = parent
        self.pack(fill=TkC.BOTH, expand=1)

        self.path = os.path.dirname(os.path.realpath(sys.argv[0]))
        self.initialize()
Ejemplo n.º 13
0
 def __init__(self, parent, width):
     '''
     Constructor
     '''
     Frame.__init__(self, parent)
     self.pack(expand=YES, fill=BOTH)
     self.makeWidgets(width)
Ejemplo n.º 14
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()
Ejemplo n.º 15
0
 def __init__(self, parent,theta,m,attr):
     Frame.__init__(self, parent)   
     self.theta=theta
     self.m=m
     self.attr=attr
     self.parent = parent        
     self.initUI()
Ejemplo n.º 16
0
    def __init__(self, parent, child):

        Frame.__init__(self, parent)
        self.parent = parent
        # create window
        self.create_window()
        self.create_menu(child)
Ejemplo n.º 17
0
    def __init__(self, parent, langton_ant):
        Frame.__init__(self, parent)
        self.parent = parent
        self.pack(fill=BOTH, expand=1)

        self.title = self.parent.title()

        self.rows = 101
        self.columns = 82
        self.cell_width = 6
        self.cell_height = 6

        self.canvas = Canvas(self, width=self.cell_width * self.columns, height=self.cell_height * self.rows,
                             borderwidth=0, highlightthickness=0)
        self.canvas.pack(side="top", fill="both", expand="true")

        self.rect = {}
        for column in range(self.columns):
            for row in range(self.rows):
                x1 = column * self.cell_width
                y1 = row * self.cell_height
                x2 = x1 + self.cell_width
                y2 = y1 + self.cell_height
                self.rect[row, column] = self.canvas.create_rectangle(x1, y1, x2, y2, fill="white", tags="rect",
                                                                      outline="black")

        self.langton_ant = langton_ant
        self.draw_result(500)
Ejemplo n.º 18
0
    def __init__(self, parent):
        Frame.__init__(self,parent, background= "white")

        self.parent = parent
        self.parent.title("Centered Window")
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()
Ejemplo n.º 19
0
    def __init__(self, master, width=0, height=0, family=None, size=None,*args, **kwargs):
        
        Frame.__init__(self, master, width = width, height= height)
        self.pack_propagate(False)

        self._min_width = width
        self._min_height = height

        self._textarea = Text(self, *args, **kwargs)
        self._textarea.pack(expand=True, fill='both')

        if family != None and size != None:
            self._font = tkFont.Font(family=family,size=size)
        else:
            self._font = tkFont.Font(family=self._textarea.cget("font"))

        self._textarea.config(font=self._font)

        # I want to insert a tag just in front of the class tag
        # It's not necesseary to guive to this tag extra priority including it at the beginning
        # For this reason I am making this search
        self._autoresize_text_tag = "autoresize_text_"+str(id(self))
        list_of_bind_tags = list(self._textarea.bindtags())
        list_of_bind_tags.insert(list_of_bind_tags.index('Text'), self._autoresize_text_tag)

        self._textarea.bindtags(tuple(list_of_bind_tags))
        self._textarea.bind_class(self._autoresize_text_tag, "<KeyPress>",self._on_keypress)
Ejemplo n.º 20
0
 def __init__(self,master=None):
     # We begin by calling the base class's constructor first
     Frame.__init__(self,master)
 
     # We now have an empty window!
     
     # This command sets up a grid structure in the window
     self.grid()
     
     # This loop generates rows and columns in the grid
     for i in range(13):
         self.rowconfigure(i,minsize=10)
     for i in range(3):
         self.columnconfigure(i,minsize=30)
     
     # These are methods which appear below the constructor
     self.defineUnits() # this sets up the units I'll be using in the converter
     self.createWidgets() # this places the elements (or widgets) in the grid
     
     # This command "binds" the user's click to a method (varChoice)
     # This method will determine which variable the user wants (Distance, Mass, Time)
     self.inputlist.bind("<Button-1>",self.__varChoice)
 
     # This is a similar command for the selection of unit
     self.unitlist.bind("<Button-1>",self.__unitChoice)
 
     # Finally, this bind reads in whatever value is in the text box when the user hits return
     # and carries out the unit conversion
     
     self.inputfield.bind("<Return>",self.__calcConversion)
Ejemplo n.º 21
0
	def __init__(self, parent,
	  color = None,
		# color to show in the well
	  width = 38, height = 38,
		# size of well
	  callback = None,
		# method to call upon color change
		#  [with argument of (WellColor)]
	  noneOkay = 0,
	  	# can the well return 'none'
	  multiple = 0,
		# does the well currently represent data with multiple colors
	  wantAlpha = 1
		# does the app want alpha supported in this well
	  ):	
		
		self._callback = callback
		self.noneOkay = noneOkay
		self._active = 0
		self.wantAlpha = wantAlpha
		self._enabled = True

		# convert width/height to pixels
		width = parent.master.winfo_pixels(width)
		height = parent.master.winfo_pixels(height)

		borderwidth = int(min(width, height) / 15)

		# border is added to width/height, so reduce them
		width = width - 2 * borderwidth
		height = height - 2 * borderwidth
		
		Frame.__init__(self, parent, width = width, height = height,
		  borderwidth = borderwidth, relief = Tkinter.RAISED)
		self.bind("<Button-1>", self.edgeClick)

		self._activeBG = 'white'
		self._inactiveBG = self['bg']

		# use a Frame around the well interior so that the relief
		# doesn't interfere with the interior's canvas coordinate
		# system
		edgewidth = int(min(width, height) / 12)
		self._wellFrame = Frame(self, borderwidth = borderwidth,
		  relief = Tkinter.SUNKEN)
		self._wellFrame.place(x=edgewidth+borderwidth, y=edgewidth+borderwidth,
		  relwidth=1, relheight=1,
		  width=0-2*(edgewidth+borderwidth), height=0-2*(edgewidth+borderwidth))
		self._well = _WellInterior(self, master=self._wellFrame,
		  borderwidth=0, highlightthickness=0)
		self._well.bind('<Configure>', self._resizeMarkers)
		self._well.pack(expand=1, fill="both")
		self._wellMarkers = None

		if not multiple and color == None and not noneOkay:
			# default to black
			self.showColor('black', doCallback=0)
		else:
			self.showColor(color=color, multiple=multiple,
								doCallback=0)
Ejemplo n.º 22
0
 def __init__(self, parent):
     Frame.__init__(self, parent)
     self.parent = parent
     
     open_button = Button(self, text = 'Calculate', relief = 'raised',
                          command=self._on_calculate, width = 23)
     open_button.pack()
Ejemplo n.º 23
0
    def __init__(self, master,x=600,y=200, onLeft=None, onRight=None, **kwargs):
        self.root=master
        self.xsize=x
        self.ysize=y
        self.onLeft=onLeft
        self.onRight=onRight
        self.ratio=100.
        Frame.__init__(self, master,width=x,height=y, **kwargs)
        self.canvas = Canvas(self, width=x, height=y, background="white")
        self.xsb = Scrollbar(self, orient="horizontal", command=self.canvas.xview)
        self.ysb = Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.ysb.set, xscrollcommand=self.xsb.set)
        self.canvas.configure(scrollregion=(0,0,x,y))

        self.xsb.grid(row=1, column=0, sticky="ew")
        self.ysb.grid(row=0, column=1, sticky="ns")
        self.canvas.grid(row=0, column=0, sticky="nsew")
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)

        self.canvas.bind("<Button-1>", self.clickL)
        self.canvas.bind("<Button-3>", self.clickR)

        # This is what enables using the mouse:
        self.canvas.bind("<ButtonPress-1>", self.move_start)
        self.canvas.bind("<B1-Motion>", self.move_move)
        #linux scroll
        self.canvas.bind("<Button-4>", self.zoomerP)
        self.canvas.bind("<Button-5>", self.zoomerM)

        self.canvas.bind_all("<Prior>", self.zoomerP)
        self.canvas.bind_all("<Next>", self.zoomerM)
        self.canvas.bind_all("E", self.zoomExtens)
        #windows scroll
        self.canvas.bind_all("<MouseWheel>",self.zoomer)
Ejemplo n.º 24
0
    def __init__(self, master=None):
        Frame.__init__(self, master)

        self.parent = master

        self.parent.geometry("640x480")
        self.parent.title(os.getenv("NAME") + " - Stdout")

        self.textedit = Text(self.parent, font="mono 10")
        self.textedit.pack(expand=True, fill=BOTH)
        buton = Button(self.parent, text="Close", command=self.quit)
        buton.pack(side=RIGHT, expand=False, padx=10, pady=10, ipadx=10)

        ysb = Scrollbar(self.textedit, orient='vertical', command=self.textedit.yview)
        xsb = Scrollbar(self.textedit, orient='horizontal', command=self.textedit.xview)

        self.textedit.configure(yscroll=ysb.set, xscroll=xsb.set)

        xsb.pack(side=BOTTOM, fill=X, expand=False)
        ysb.pack(side=RIGHT, fill=Y, expand=False)

        self.textedit.pack(side=TOP, fill=BOTH, expand=True)


        self.show_file()
Ejemplo n.º 25
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()
Ejemplo n.º 26
0
    def __init__(self, parent, mw):
        Frame.__init__(self, parent)
        parent.configure(bg="MediumTurquoise")
        self.parent = parent
        self.mw = mw

        # change font size depending on screen dimension
        screen_width = self.parent.winfo_screenwidth()
        screen_height = self.parent.winfo_screenheight()

        # projector setting
        if screen_width == 1280:
	    self.customFont1 = tkFont.Font(family="LMMono10", size=20)
	    self.customFont = tkFont.Font(family="Pupcat", size=20, weight=tkFont.BOLD)
	    self.customFont2 = tkFont.Font(family="LMMono10", size=14)

	# single screen setting
	elif screen_width == 1920:
	    self.customFont1 = tkFont.Font(family="LMMono10", size=18)
	    self.customFont = tkFont.Font(family="Pupcat", size=16, weight=tkFont.BOLD)
            self.customFont2 = tkFont.Font(family="LMMono10", size=14)
            
	# double screen setting
	else:
            self.customFont1 = tkFont.Font(family="LMMono10", size=18)
            self.customFont = tkFont.Font(family="Pupcat", size=16, weight=tkFont.BOLD)
            self.customFont2 = tkFont.Font(family="LMMono10", size=14)

        self.initLogo()
        self.initToolbar()
        self.initScreen()
Ejemplo n.º 27
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()
Ejemplo n.º 28
0
    def __init__(self, parent, controller):
        Frame.__init__(self, parent)
        self.controller = controller
        self.size = None
        self.first_player = None
        self._board = TicTacToe(4)
        self.new_ai = AI('O', self._board)
        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")
        label = Label(self, text="The 4X4 Single Player is a beta version. It might take computer\n"
                                 "some time to play. We appreciate your patience.", font=SUB_TITLE_FONT)
        label.grid(row=8, column=0, columnspan=4)
        self.update()
Ejemplo n.º 29
0
	def __init__(self, config_file_handler, master=None):
		"""Builds and initializes the GUI as a Interface type if instance.
		
		First, the Interface instance attributes are created, additionally
		the following instance attributes are created:
		solve_action_set -- Set of methods for the solve menu actions
		settings_action_set -- Set of methods for the settings menu actions
		play_action_set -- Set of methods for the play menu actions
		gui_builder -- Set of methods for building the PAC Sudoku GUI
		config_file -- XMLFileHandler object with the config file loaded
		interactive -- Sudokuinteractive initialized as None
		violation -- Violation flag set to False
		currently_editing -- Canvas image ID of a square initialized as None
		timer -- Sudoku timer
		_timer_increment -- Used to increment by 1 second the timer
		
		"""
		Interface.__init__(self, config_file_handler)
		self.solve_action_set = SudokuGUISolveActionSet(self)
		self.settings_action_set = SudokuGUISettingsActionSet(self)
		self.play_action_set = SudokuGUIPlayActionSet(self)
		self.gui_builder = SudokuGUIBuilder(self)
		self.config_file = config_file_handler
		self.interactive = None
		self.violation = False
		self.currently_editing = None
		self.timer = datetime(1900, 1, 1)
		self._timer_increment = timedelta(seconds=1)
		Frame.__init__(self, master)
		self.pack()
		self._create_widgets()
Ejemplo n.º 30
0
    def __init__(self, master=None, cnf={}, **kw):
        Frame.__init__(self, master, cnf,
                       background=FRAME_COLOR,
                       borderwidth=BORDER_WIDTH,
                       relief=RIDGE)

        self.pack(side=TOP, expand=1, fill=X)
Ejemplo n.º 31
0
    def __init__(self,
                 master,
                 columns,
                 data=None,
                 command=None,
                 editable=True,
                 sort=True,
                 select_mode=None,
                 autoscroll=True,
                 vscrollbar=True,
                 hscrollbar=False,
                 heading_anchor=CENTER,
                 cell_anchor=W,
                 style=None,
                 scrollbar_background=None,
                 scrollbar_troughcolor=None,
                 height=None,
                 padding=None,
                 adjust_heading_to_content=False,
                 stripped_rows=None,
                 selection_background=None,
                 selection_foreground=None,
                 cell_background=None,
                 cell_foreground=None,
                 cell_font=None,
                 field_background=None,
                 heading_font=None,
                 heading_background=None,
                 heading_foreground=None,
                 cell_pady=2,
                 column_header=True,
                 row_numbers=True,
                 entry_background="#d6d6d6",
                 entry_foreground=None,
                 entry_validatecommand=None,
                 entry_selectbackground="#1BA1E2",
                 entry_selectborderwidth=None,
                 entry_selectforeground=None,
                 entry_font="TkDefaultFont",
                 rowlabel_anchor=E,
                 rowlabel_minwidth=0,
                 rowlabel_hoverbackground="#FFFFFF",
                 frame_relief=None,
                 frame_borderwidth=None,
                 frame_background=None):

        frame_kwargs = {}

        if frame_relief is not None:
            frame_kwargs["relief"] = frame_relief

        if frame_borderwidth is not None:
            frame_kwargs["borderwidth"] = frame_borderwidth

        if frame_background is not None:
            frame_kwargs["background"] = frame_background

        Frame.__init__(self,
                       master,
                       class_="Multicolumn_Listbox",
                       **frame_kwargs)

        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(1, weight=1)

        self._multicolumn_listbox = Multicolumn_Listbox(
            self,
            columns,
            data=data,
            command=command,
            sort=sort,
            select_mode=select_mode,
            heading_anchor=heading_anchor,
            cell_anchor=cell_anchor,
            style=style,
            height=height,
            padding=padding,
            adjust_heading_to_content=adjust_heading_to_content,
            stripped_rows=stripped_rows,
            selection_background=selection_background,
            selection_foreground=selection_foreground,
            cell_background=cell_background,
            cell_foreground=cell_foreground,
            cell_font=cell_font,
            field_background=field_background,
            heading_font=heading_font,
            heading_background=heading_background,
            heading_foreground=heading_foreground,
            cell_pady=cell_pady,
            headers=column_header)

        self._multicolumn_listbox.interior.grid(row=0,
                                                column=1,
                                                sticky=N + E + W + S)

        self._mousewheel_detection = True

        if row_numbers:
            self._row_numbers = Row_Header(
                self,
                font=self._multicolumn_listbox.font,
                row_height=self._multicolumn_listbox.row_height,
                row_minwidth=rowlabel_minwidth,
                hover_background=rowlabel_hoverbackground,
                anchor=rowlabel_anchor,
                onclick=self._on_click_row_label)
            self._row_numbers.grid(row=0, column=0, sticky=N + S + E)

            self._multicolumn_listbox.interior.bind(
                "<Map>", self._place_vertically_row_numbers)
        else:
            self._row_numbers = None

        if editable:
            self._selected_cell = None
            self._entry_popup = None

            self._multicolumn_listbox.interior.bind("<1>", self._edit_cell)

            def configure(event):
                """
                if self._entry_popup:
                    self._entry_popup.destroy()
                return
                """

                self._multicolumn_listbox.interior.update_idletasks()
                self._update_position_of_entry()

            self._multicolumn_listbox.interior.bind("<Configure>", configure)

            self._entry_kwargs = entry_kwargs = {}
            if entry_background is not None:
                entry_kwargs["background"] = entry_background

            if entry_foreground is not None:
                entry_kwargs["foreground"] = entry_foreground

            if entry_validatecommand is not None:
                entry_kwargs["validatecommand"] = entry_validatecommand

            if entry_selectbackground is not None:
                entry_kwargs["selectbackground"] = entry_selectbackground

            if entry_selectforeground is not None:
                entry_kwargs["selectforeground"] = entry_selectforeground

            if entry_font is not None:
                entry_kwargs["font"] = entry_font

        if command is not None:
            self._command = command
            self._multicolumn_listbox.interior.bind("<<TreeviewSelect>>",
                                                    self._on_select)

        scrollbar_kwargs = {}
        if scrollbar_background is not None:
            scrollbar_kwargs["background"] = scrollbar_background

        if scrollbar_troughcolor is not None:
            scrollbar_kwargs["throughcolor"] = scrollbar_troughcolor

        if vscrollbar:
            if editable:
                if row_numbers:

                    def yview_command(*args):

                        self._multicolumn_listbox.interior.yview(*args)
                        self._row_numbers.yview(*args)

                        self._update_position_of_entry()
                else:

                    def yview_command(*args):
                        self._multicolumn_listbox.interior.yview(*args)
                        self._update_position_of_entry()
            else:
                if row_numbers:

                    def yview_command(*args):
                        self._multicolumn_listbox.interior.yview(*args)
                        self._row_numbers.yview(*args)
                else:
                    yview_command = self._multicolumn_listbox.interior.yview

            self._vbar = Scrollbar(self,
                                   takefocus=0,
                                   command=yview_command,
                                   **scrollbar_kwargs)
            self._vbar.grid(row=0, column=2, sticky=N + S)

            def yscrollcommand(first, last):
                first, last = float(first), float(last)
                if first <= 0 and last >= 1:
                    if self._mousewheel_detection:
                        if autoscroll:
                            self._vbar.grid_remove()

                        if row_numbers:
                            unbind_function_onMouseWheel(
                                self._multicolumn_listbox.interior)
                        self._mousewheel_detection = False
                else:
                    if not self._mousewheel_detection:
                        if autoscroll:
                            self._vbar.grid()

                        if row_numbers:
                            bind_function_onMouseWheel(
                                self._row_numbers,
                                "y",
                                binding_widget=self._multicolumn_listbox.
                                interior,
                                unit="pages")
                        self._mousewheel_detection = True

                self._vbar.set(first, last)
                if editable:
                    self._update_position_of_entry()

            self._multicolumn_listbox.interior.config(
                yscrollcommand=yscrollcommand)

        if hscrollbar:
            if editable:

                def xview_command(*args):
                    self._multicolumn_listbox.interior.xview(*args)
                    self._update_position_of_entry()
            else:
                xview_command = self._multicolumn_listbox.interior.xview

            self._hbar = Scrollbar(self,
                                   takefocus=0,
                                   command=xview_command,
                                   **scrollbar_kwargs)
            self._hbar.grid(row=1, column=1, sticky=E + W)

            if autoscroll:
                if editable:

                    def xscrollcommand(f, l, self=self):
                        make_autoscroll(self._hbar, f, l)
                        self._update_position_of_entry()
                else:

                    def xscrollcommand(f, l, hbar=self._hbar):
                        make_autoscroll(hbar, f, l)

                self._multicolumn_listbox.interior.config(
                    xscrollcommand=xscrollcommand)
            else:
                self._multicolumn_listbox.interior.config(
                    xscrollcommand=self._hbar.set)
Ejemplo n.º 32
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        pad_x = 10
        pad_y = 5
        buttonWidth = 25
        self.pdflist = []
        self.fname = None
        self.workDir = None
        self.workDirText = StringVar()
        self.workDirText.set("Folder roboczy: ")
        self.var = IntVar()

        self.setWorkDir = Button(self,
                                 text='Wybierz folder roboczy',
                                 command=self.setDir,
                                 width=buttonWidth)
        self.setWorkDir.grid(row=1, column=0, sticky=W, padx=pad_x, pady=pad_y)

        self.multiFIleButton = Button(self,
                                      text='Wybierz pliki do płączenia',
                                      command=self.getMulitiFile,
                                      width=buttonWidth)
        self.multiFIleButton.grid(row=1,
                                  column=1,
                                  sticky=W,
                                  padx=pad_x,
                                  pady=pad_y)

        self.removeCheckkButton = Checkbutton(self,
                                              variable=self.var,
                                              text="Usun pliki robocze",
                                              width=buttonWidth)
        self.removeCheckkButton.grid(row=2,
                                     column=1,
                                     sticky=W,
                                     padx=pad_x,
                                     pady=pad_y)

        self.saveFileButton = Button(self,
                                     text='Plik wyjściowy',
                                     command=self.saveFile,
                                     width=buttonWidth)
        self.saveFileButton.grid(row=2,
                                 column=0,
                                 sticky=W,
                                 padx=pad_x,
                                 pady=pad_y)

        self.workDirLabel = Label(self, textvariable=self.workDirText)
        self.workDirLabel.grid(row=0, column=0, columnspan=2, sticky=W)

        self.runAppButton = Button(self,
                                   text='Polacz pliki',
                                   command=self.mergeCommand,
                                   width=buttonWidth)
        self.runAppButton.grid(row=3,
                               column=0,
                               columnspan=2,
                               padx=pad_x,
                               pady=pad_y)

        self.exitButton = Button(self,
                                 text='Exit',
                                 command=self.close_window,
                                 width=15)
        self.exitButton.grid(row=4,
                             column=1,
                             sticky=SE,
                             padx=pad_x,
                             pady=pad_y)

        self.pack(anchor='nw')
Ejemplo n.º 33
0
    def __init__(self, parent,gridrow):
        "Initialise the ``Patrol``."

        padx, pady = 10, 5  # formatting
        sticky = tk.EW + tk.N  # full width, stuck to the top
        anchor = tk.NW

        Frame.__init__(
            self,
            parent
        )
        self.ships=[]

        self.IMG_PREV = tk.PhotoImage(file = u'{}\\icons\\left_arrow.gif'.format(CanonnPatrol.plugin_dir))
        self.IMG_NEXT = tk.PhotoImage(file = u'{}\\icons\\right_arrow.gif'.format(CanonnPatrol.plugin_dir))

        self.patrol_config=os.path.join(Release.plugin_dir,'data','EDMC-Canonn.patrol')


        self.canonnbtn=tk.IntVar(value=config.getint("HideCanonn"))
        self.factionbtn=tk.IntVar(value=config.getint("HideFaction"))
        self.hideshipsbtn=tk.IntVar(value=config.getint("HideShips"))
        self.copypatrolbtn=tk.IntVar(value=config.getint("CopyPatrol"))

        self.canonn=self.canonnbtn.get()
        self.faction=self.factionbtn.get()
        self.hideships=self.hideshipsbtn.get()
        self.copypatrol=self.copypatrolbtn.get()

        self.columnconfigure(1, weight=1)
        self.columnconfigure(4, weight=4)
        self.grid(row = gridrow, column = 0, sticky="NSEW",columnspan=2)

        ## Text Instructions for the patrol
        self.label=tk.Label(self, text=  "Patrol:")
        self.label.grid(row = 0, column = 0, sticky=sticky)

        self.hyperlink=PatrolLink(self)
        self.hyperlink.grid(row = 0, column = 2)
        self.distance=tk.Label(self, text=  "...")
        self.distance.grid(row = 0, column = 3,sticky="NSEW")
        self.distance.grid_remove()

        ## Text Instructions for the patrol
        self.infolink=InfoLink(self)
        self.infolink.grid(row = 1, column = 0,sticky="NSEW",columnspan=5)
        self.infolink.grid_remove()

        #buttons for the patrol
        self.prev=tk.Button(self, text="Prev", image=self.IMG_PREV, width=14, height=14,borderwidth=0)
        #self.submit=tk.Button(self, text="Open")
        self.next=tk.Button(self, text="Next", image=self.IMG_NEXT, width=14, height=14,borderwidth=0)
        self.prev.grid(row = 0, column = 1,sticky="W")

        #self.submit.grid(row = 2, column = 1,sticky="NSW")
        self.next.grid(row = 0, column = 4,sticky="E")
        self.next.bind('<Button-1>',self.patrol_next)
        self.prev.bind('<Button-1>',self.patrol_prev)

        self.prev.grid_remove()
        self.next.grid_remove()

        self.excluded={}

        self.patrol_list=[]
        self.capi_update=False
        self.patrol_count=0
        self.patrol_pos=0
        self.minutes=0
        self.visible()
        self.cmdr=""
        self.nearest={}

        self.system=""

        self.body=""
        self.lat=""
        self.lon=""

        self.started=False

        # wait 10 seconds before updatinb the ui
        self.after(1000, self.update_ui)
Ejemplo n.º 34
0
    def __init__(self,
                 master,
                 columns,
                 column_weights=None,
                 column_minwidths=None,
                 height=None,
                 minwidth=20,
                 minheight=20,
                 padx=5,
                 pady=5,
                 cell_font=None,
                 cell_foreground="black",
                 cell_background="white",
                 cell_anchor=W,
                 header_font=None,
                 header_background="white",
                 header_foreground="black",
                 header_anchor=CENTER,
                 bordercolor="#999999",
                 innerborder=True,
                 outerborder=True,
                 stripped_rows=("#EEEEEE", "white"),
                 on_change_data=None):
        outerborder_width = 1 if outerborder else 0

        Frame.__init__(self,
                       master,
                       highlightbackground=bordercolor,
                       highlightcolor=bordercolor,
                       highlightthickness=outerborder_width,
                       bd=0)

        self._cell_background = cell_background
        self._cell_foreground = cell_foreground
        self._cell_font = cell_font
        self._cell_anchor = cell_anchor

        self._number_of_rows = 0
        self._number_of_columns = len(columns)

        self._stripped_rows = stripped_rows

        self._padx = padx
        self._pady = pady

        self._bordercolor = bordercolor
        self._innerborder_width = 1 if innerborder else 0

        self._data_vars = []

        self._columns = columns

        for j in range(len(columns)):
            column_name = columns[j]

            header_cell = Header_Cell(self,
                                      text=column_name,
                                      borderwidth=self._innerborder_width,
                                      font=header_font,
                                      background=header_background,
                                      foreground=header_foreground,
                                      padx=padx,
                                      pady=pady,
                                      bordercolor=bordercolor,
                                      anchor=header_anchor)
            header_cell.grid(row=0, column=j, sticky=N + E + W + S)

        if column_weights is None:
            for j in range(len(columns)):
                self.grid_columnconfigure(j, weight=1)
        else:
            for j, weight in enumerate(column_weights):
                self.grid_columnconfigure(j, weight=weight)

        if column_minwidths is not None:
            self.update_idletasks()
            for j, minwidth in enumerate(column_minwidths):
                if minwidth is None:
                    header_cell = self.grid_slaves(row=0, column=j)[0]
                    minwidth = header_cell.winfo_reqwidth()
                self.grid_columnconfigure(j, minsize=minwidth)

        if height is not None:
            self._append_n_rows(height)

        self._on_change_data = on_change_data
 def __init__(self, master=None):
     Frame.__init__(self, master)
     Pack.config(self)
     self.createWidgets()
     self.count = 0
Ejemplo n.º 36
0
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.parent = parent

        self.initUI()
Ejemplo n.º 37
0
    def __init__(self,
                 master,
                 text=None,
                 borderwidth=2,
                 width=0,
                 height=16,
                 interior_padx=0,
                 interior_pady=8,
                 background=None,
                 caption_separation=4,
                 caption_font=None,
                 caption_builder=None,
                 icon_x=5):
        Frame.__init__(self, master)
        if background is None:
            background = self.cget("background")

        self.configure(background=background)

        self._is_opened = False

        self._interior_padx = interior_padx
        self._interior_pady = interior_pady

        self._iconOpen = PhotoImage(
            data=
            "R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADNhi63BMgyinFAy0HC3Xj2EJoIEOM32WeaSeeqFK+say+2azUi+5ttx/QJeQIjshkcsBsOp/MBAA7"
        )
        self._iconClose = PhotoImage(
            data=
            "R0lGODlhEAAQAKIAAP///9TQyICAgEBAQAAAAAAAAAAAAAAAACwAAAAAEAAQAAADMxi63BMgyinFAy0HC3XjmLeA4ngpRKoSZoeuDLmo38mwtVvKu93rIo5gSCwWB8ikcolMAAA7"
        )

        height_of_icon = max(self._iconOpen.height(), self._iconClose.height())
        width_of_icon = max(self._iconOpen.width(), self._iconClose.width())

        containerFrame_pady = (height_of_icon // 2) + 1

        self._height = height
        self._width = width

        self._containerFrame = Frame(self,
                                     borderwidth=borderwidth,
                                     width=width,
                                     height=height,
                                     relief=RIDGE,
                                     background=background)
        self._containerFrame.pack(expand=True,
                                  fill=X,
                                  pady=(containerFrame_pady, 0))

        self.interior = Frame(self._containerFrame, background=background)

        self._collapseButton = Label(self,
                                     borderwidth=0,
                                     image=self._iconOpen,
                                     relief=RAISED)
        self._collapseButton.place(in_=self._containerFrame,
                                   x=icon_x,
                                   y=-(height_of_icon // 2),
                                   anchor=N + W,
                                   bordermode="ignore")
        self._collapseButton.bind("<Button-1>", lambda event: self.toggle())

        if caption_builder is None:
            self._captionLabel = Label(self,
                                       anchor=W,
                                       borderwidth=1,
                                       text=text)
            if caption_font is not None:
                self._captionLabel.configure(font=caption_font)
        else:
            self._captionLabel = caption_builder(self)

            if not isinstance(self._captionLabel, Widget):
                raise Exception(
                    "'caption_builder' doesn't return a tkinter widget")

        self.after(
            0, lambda: self._place_caption(caption_separation, icon_x,
                                           width_of_icon))
    def __init__(self, master, plotgroup, **params):
        """
        If your parameter should be available in history, add its name
        to the params_in_history list, otherwise it will be disabled
        in historical views.
        """

        tk.TkParameterized.__init__(self,
                                    master,
                                    extraPO=plotgroup,
                                    msg_handler=master.status,
                                    **params)
        Frame.__init__(self, master.content)

        self.parent = master  #CEBALERT
        self.setup_plotgroup()

        self.canvases = []
        self.plot_labels = []

        ### JCALERT! Figure out why we need that!
        self._num_labels = 0

        self.plotgroups_history = []
        self.history_index = 0
        self.params_in_history = []  # parameters valid to adjust in history

        # Factor for reducing or enlarging the Plots (where 1.2 = 20% change)
        self.zoom_factor = 1.2

        # CEBALERT: rename these frames
        self.control_frame_1 = Frame(master.noscroll)
        self.control_frame_1.pack(side=TOP, expand=NO, fill=X)

        self.control_frame_2 = Frame(master.noscroll)
        self.control_frame_2.pack(side=TOP, expand=NO, fill=X)

        self.plot_frame = Tkinter.LabelFrame(self, text=self.plotgroup.name)
        self.plot_frame.pack(side=TOP, expand=YES, fill=BOTH)  #,padx=5,pady=5)

        # CB: why did I need a new frame after switching to 8.5?
        # I've forgotten what i changed.
        self.plot_container = Tkinter.Frame(self.plot_frame)
        self.plot_container.pack(anchor="center")

        # Label does have a wraplength option...but it's in screen
        # units. Surely tk has a function to convert between
        # text and screen units?
        no_plot_note_text = """
Press Refresh on the pre-plot hooks to generate the plot, after modifying the hooks below if necessary. Note that Refreshing may take some time.

Many hooks accept 'display=True' so that the progress can be viewed in an open Activity window, e.g. for debugging.
"""

        self.no_plot_note = Label(self.plot_container,
                                  text=no_plot_note_text,
                                  justify="center",
                                  wraplength=350)
        self.no_plot_note_enabled = False

        self.control_frame_3 = Frame(master.noscroll_bottom)
        self.control_frame_3.pack(side=TOP, expand=NO, fill=X)

        self.control_frame_4 = Frame(self)
        self.control_frame_4.pack(side=TOP, expand=NO, fill=NONE)

        self.updatecommand_frame = Frame(self.control_frame_3)
        self.updatecommand_frame.pack(side=TOP, expand=YES, fill=X)

        self.plotcommand_frame = Frame(self.control_frame_3)
        self.plotcommand_frame.pack(side=TOP, expand=YES, fill=X)

        # CEBALERT: replace
        self.messageBar = self.parent.status

        self.pack_param('pre_plot_hooks',
                        parent=self.updatecommand_frame,
                        expand='yes',
                        fill='x',
                        side='left')

        self.pack_param('Refresh',
                        parent=self.updatecommand_frame,
                        on_set=self.refresh,
                        side='right')
        self.params_in_history.append('Refresh')

        self.pack_param('plot_hooks',
                        parent=self.plotcommand_frame,
                        expand='yes',
                        fill='x',
                        side='left')
        # CEBALERT: should disable unless data exists.
        self.pack_param('Redraw',
                        parent=self.plotcommand_frame,
                        on_set=self.redraw_plots,
                        side='right')

        self.pack_param('Enlarge',
                        parent=self.control_frame_1,
                        on_set=self.enlarge_plots,
                        side=LEFT)
        self.params_in_history.append(
            'Enlarge')  # CEBNOTE: while it's a GUI op

        self.pack_param('Reduce',
                        parent=self.control_frame_1,
                        on_set=self.reduce_plots,
                        side=LEFT)
        self.params_in_history.append('Reduce')

        if topo.tkgui.TK_SUPPORTS_DOCK:
            self.pack_param("dock",
                            parent=self.control_frame_1,
                            on_set=self.set_dock,
                            side=LEFT)

        # Don't need to add these two to params_in_history because their
        # availability is controlled separately (determined by what's
        # in the history)
        self.pack_param('Back',
                        parent=self.control_frame_2,
                        on_set=lambda x=-1: self.navigate_pg_history(x),
                        side=LEFT)

        self.pack_param('Fwd',
                        parent=self.control_frame_2,
                        on_set=lambda x=+1: self.navigate_pg_history(x),
                        side=LEFT)

        #################### RIGHT-CLICK MENU STUFF ####################
        ### Right-click menu for canvases; subclasses can add cascades
        ### or insert commands on the existing cascades.
        self._canvas_menu = tk.Menu(self, tearoff=0)  #self.context_menu

        self._unit_menu = tk.Menu(self._canvas_menu, tearoff=0)
        self._canvas_menu.add_cascade(menu=self._unit_menu,
                                      state=DISABLED,
                                      indexname='unit_menu')

        self._canvas_menu.add_separator()

        # CEBALERT: scheme for enabling/disabling menu items ('disable
        # items hack') needs to be generalized. What we have now is
        # just a mechanism to disable/enable cfs/rfs plots as
        # necessary. Hack includes the attribute below as well as
        # other items marked 'disable items hack'.
        # (Note that tk 8.5 has better handling of state switching
        # (using flags for each state, I think), so presumably this
        # can be cleaned up easily.)
        self._unit_menu_updaters = {}

        self._sheet_menu = tk.Menu(self._canvas_menu, tearoff=0)
        self._canvas_menu.add_cascade(menu=self._sheet_menu,
                                      state=DISABLED,
                                      indexname='sheet_menu')
        self._canvas_menu.add_separator()

        self.update_plot_frame(plots=False)
Ejemplo n.º 39
0
    def __init__(self, parent):
        Frame.__init__(self, parent)

        parent.title('Nibbles')
        self.board = Board(parent)
        self.pack()
Ejemplo n.º 40
0
 def __init__(self, master=None):
     Frame.__init__(self, master)
     master.wm_title("Image examples")
     self.pack()
     self.createWidgets()
Ejemplo n.º 41
0
 def __init__(self, parent):
     Frame.__init__(self, parent, width=190)
Ejemplo n.º 42
0
    def __init__(self, master, buttons=('interpret', 'asis'), **kw):
        Frame.__init__(self, master, **kw)
        self.text = ''
        self.interpret = 1
        self.editPool = Entry(self,
                              width=50,
                              state='disabled',
                              font="Helvetica 12")
        self.editPool.pack(side='left')

        self.editPool.bind('<Return>', self._interpretButtonPressed)
        self.editPool.bind('<Escape>', self._cancel)

        self.editPool.bind('<Control-s>', lambda e: self._tag_it("sub"))
        self.editPool.bind('<Control-S>', lambda e: self._tag_it("sup"))
        self.editPool.bind('<Control-i>', lambda e: self._tag_it("i"))
        self.editPool.bind('<Control-b>', lambda e: self._tag_it("b"))

        self.editPool.bind("<KeyPress>", self._key)

        if 'interpret' in buttons:
            pix = Store.app.request('pixmap', name='interpret')
            self.interpretButton = Button(self,
                                          text=_('Interpret'),
                                          image=pix,
                                          command=self._interpretButtonPressed,
                                          state='disabled',
                                          bd=config.border_width)
            Store.app.balloon.bind(self.interpretButton,
                                   _('Interpret text (where applicable)'))
            self.interpretButton.pack(side='left')
        else:
            self.interpretButton = None

        if 'asis' in buttons:
            pix = Store.app.request('pixmap', name='asis')
            self.setButton = Button(self,
                                    image=pix,
                                    text=_('As is'),
                                    command=self._setButtonPressed,
                                    state='disabled',
                                    bd=config.border_width)
            Store.app.balloon.bind(self.setButton,
                                   _('Leave text as is - do not interpret'))
            self.setButton.pack(side='left')
        else:
            self.setButton = None

        pix = Store.app.request('pixmap', name='subnum')
        self.numbersToSubButton = Button(
            self,
            image=pix,
            text=_('Sub numbers'),
            command=self._numbersToSubButtonPressed,
            state='disabled',
            bd=config.border_width)
        Store.app.balloon.bind(self.numbersToSubButton,
                               _('Convert numbers to subscript'))
        self.numbersToSubButton.pack(side='left')

        # text decoration
        decorFrame = Frame(self)
        decorFrame.pack(padx=5, side="left")
        for i in self.font_decorations:
            pix = Store.app.request('pixmap', name=i)
            self.__dict__[i] = Button(
                self,
                image=pix,
                command=misc.lazy_apply(self._tag_it,
                                        (self.font_decorations_to_html[i], )),
                state='disabled',
                text=self.font_decorations_to_names[i],
                bd=config.border_width)
            Store.app.balloon.bind(self.__dict__[i],
                                   self.font_decorations_to_names[i])
            self.__dict__[i].pack(side="left")

        # special characters
        pix = Store.app.request('pixmap', name='specialchar')
        self.specialCharButton = Button(self,
                                        image=pix,
                                        text=_('Special Character'),
                                        command=self._specialCharButtonPressed,
                                        state='disabled',
                                        bd=config.border_width)
        Store.app.balloon.bind(self.specialCharButton,
                               _('Insert a special character'))
        self.specialCharButton.pack(side='left')
        self.active = False
Ejemplo n.º 43
0
 def __init__(self, master, name):
     Frame.__init__(self, master)
     self.tab_name = name
Ejemplo n.º 44
0
    def __init__(self, parent):
        Frame.__init__(self, parent, background="white")

        self.parent = parent

        self.initUI()
Ejemplo n.º 45
0
    def __init__(self,
                 master,
                 columns,
                 column_weights=None,
                 column_minwidths=None,
                 height=500,
                 minwidth=20,
                 minheight=20,
                 padx=5,
                 pady=5,
                 cell_font=None,
                 cell_foreground="black",
                 cell_background="white",
                 cell_anchor=W,
                 header_font=None,
                 header_background="white",
                 header_foreground="black",
                 header_anchor=CENTER,
                 bordercolor="#999999",
                 innerborder=True,
                 outerborder=True,
                 stripped_rows=("#EEEEEE", "white"),
                 on_change_data=None,
                 mousewheel_speed=2,
                 scroll_horizontally=False,
                 scroll_vertically=True):
        outerborder_width = 1 if outerborder else 0

        Frame.__init__(self, master, bd=0)

        self._cell_background = cell_background
        self._cell_foreground = cell_foreground
        self._cell_font = cell_font
        self._cell_anchor = cell_anchor

        self._stripped_rows = stripped_rows

        self._padx = padx
        self._pady = pady

        self._bordercolor = bordercolor
        self._innerborder_width = 1 if innerborder else 0

        self._data_vars = []

        self._columns = columns

        self._number_of_rows = 0
        self._number_of_columns = len(columns)

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(1, weight=1)

        self._head = Frame(self,
                           highlightbackground=bordercolor,
                           highlightcolor=bordercolor,
                           highlightthickness=outerborder_width,
                           bd=0)
        self._head.grid(row=0, column=0, sticky=E + W)

        header_separator = False if outerborder else True

        for j in range(len(columns)):
            column_name = columns[j]

            header_cell = Header_Cell(self._head,
                                      text=column_name,
                                      borderwidth=self._innerborder_width,
                                      font=header_font,
                                      background=header_background,
                                      foreground=header_foreground,
                                      padx=padx,
                                      pady=pady,
                                      bordercolor=bordercolor,
                                      anchor=header_anchor,
                                      separator=header_separator)
            header_cell.grid(row=0, column=j, sticky=N + E + W + S)

        add_scrollbars = scroll_horizontally or scroll_vertically
        if add_scrollbars:
            if scroll_horizontally:
                xscrollbar = Scrollbar(self, orient=HORIZONTAL)
                xscrollbar.grid(row=2, column=0, sticky=E + W)
            else:
                xscrollbar = None

            if scroll_vertically:
                yscrollbar = Scrollbar(self, orient=VERTICAL)
                yscrollbar.grid(row=1, column=1, sticky=N + S)
            else:
                yscrollbar = None

            scrolling_area = Scrolling_Area(
                self,
                width=self._head.winfo_reqwidth(),
                height=height,
                scroll_horizontally=scroll_horizontally,
                xscrollbar=xscrollbar,
                scroll_vertically=scroll_vertically,
                yscrollbar=yscrollbar)
            scrolling_area.grid(row=1, column=0, sticky=E + W)

            self._body = Frame(scrolling_area.innerframe,
                               highlightbackground=bordercolor,
                               highlightcolor=bordercolor,
                               highlightthickness=outerborder_width,
                               bd=0)
            self._body.pack()

            def on_change_data():
                scrolling_area.update_viewport()

        else:
            self._body = Frame(self,
                               height=height,
                               highlightbackground=bordercolor,
                               highlightcolor=bordercolor,
                               highlightthickness=outerborder_width,
                               bd=0)
            self._body.grid(row=1, column=0, sticky=N + E + W + S)

        if column_weights is None:
            for j in range(len(columns)):
                self._body.grid_columnconfigure(j, weight=1)
        else:
            for j, weight in enumerate(column_weights):
                self._body.grid_columnconfigure(j, weight=weight)

        if column_minwidths is not None:
            for j, minwidth in enumerate(column_minwidths):
                if minwidth is None:
                    header_cell = self._head.grid_slaves(row=0, column=j)[0]
                    minwidth = header_cell.winfo_reqwidth()

                self._body.grid_columnconfigure(j, minsize=minwidth)
        else:
            for j in range(len(columns)):
                header_cell = self._head.grid_slaves(row=0, column=j)[0]
                minwidth = header_cell.winfo_reqwidth()

                self._body.grid_columnconfigure(j, minsize=minwidth)

        self._on_change_data = on_change_data
Ejemplo n.º 46
0
 def __init__(self, master=None, init_name=None):
     Frame.__init__(self, master)
     self.tabs = {}
     self.buttons = {}
     self.current_tab = None
     self.init_name = init_name
Ejemplo n.º 47
0
 def __init__(self, root, gui):
     Frame.__init__(self, root)
Ejemplo n.º 48
0
 def __init__(self, master=None):
     Frame.__init__(self, master, bg='black')
     self.pack(expand=YES, fill=BOTH)
     self.window_init()
     self.createWidgets()
Ejemplo n.º 49
0
 def __init__(self, master, grille=None):
     Frame.__init__(self, master)
     self.grille = grille
Ejemplo n.º 50
0
    def __init__(self,
                 master,
                 width=None,
                 anchor=N,
                 height=None,
                 mousewheel_speed=2,
                 scroll_horizontally=True,
                 xscrollbar=None,
                 scroll_vertically=True,
                 yscrollbar=None,
                 outer_background=None,
                 inner_frame=Frame,
                 **kw):
        Frame.__init__(self, master, class_=self.__class__)

        if outer_background:
            self.configure(background=outer_background)

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self._width = width
        self._height = height

        self.canvas = Canvas(self,
                             background=outer_background,
                             highlightthickness=0,
                             width=width,
                             height=height)
        self.canvas.grid(row=0, column=0, sticky=N + E + W + S)

        if scroll_vertically:
            if yscrollbar is not None:
                self.yscrollbar = yscrollbar
            else:
                self.yscrollbar = Scrollbar(self, orient=VERTICAL)
                self.yscrollbar.grid(row=0, column=1, sticky=N + S)

            self.canvas.configure(yscrollcommand=self.yscrollbar.set)
            self.yscrollbar['command'] = self.canvas.yview
        else:
            self.yscrollbar = None

        if scroll_horizontally:
            if xscrollbar is not None:
                self.xscrollbar = xscrollbar
            else:
                self.xscrollbar = Scrollbar(self, orient=HORIZONTAL)
                self.xscrollbar.grid(row=1, column=0, sticky=E + W)

            self.canvas.configure(xscrollcommand=self.xscrollbar.set)
            self.xscrollbar['command'] = self.canvas.xview
        else:
            self.xscrollbar = None

        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.innerframe = inner_frame(self.canvas, **kw)
        self.innerframe.pack(anchor=anchor)

        self.canvas.create_window(0,
                                  0,
                                  window=self.innerframe,
                                  anchor='nw',
                                  tags="inner_frame")

        self.canvas.bind('<Configure>', self._on_canvas_configure)

        Mousewheel_Support(self).add_support_to(self.canvas,
                                                xscrollbar=self.xscrollbar,
                                                yscrollbar=self.yscrollbar)
Ejemplo n.º 51
0
    def __init__(self,
                 master,
                 entry_width=60,
                 entry_font=None,
                 entry_background="white",
                 entry_highlightthickness=1,
                 button_text="Search",
                 button_ipadx=10,
                 button_background="#ffffff",
                 button_foreground="black",
                 button_font=None,
                 opacity=0.8,
                 placeholder=None,
                 placeholder_font=None,
                 placeholder_color="grey",
                 spacing=3,
                 command=None):
        Frame.__init__(self, master)

        self._command = command

        self.entry = Entry(self,
                           width=entry_width,
                           background=entry_background,
                           highlightcolor=button_background,
                           highlightthickness=entry_highlightthickness)
        self.entry.pack(side=LEFT, fill=BOTH, ipady=1, padx=(0, spacing))

        if entry_font:
            self.entry.configure(font=entry_font)

        if placeholder:
            add_placeholder(self.entry,
                            placeholder,
                            color=placeholder_color,
                            font=placeholder_font)

        self.entry.bind("<Escape>",
                        lambda event: self.entry.nametowidget(".").focus())
        self.entry.bind("<Return>", self._on_execute_command)

        opacity = float(opacity)

        if button_background.startswith("#"):
            r, g, b = hex2rgb(button_background)
        else:
            r, g, b = master.winfo_rgb(button_background)

        r = int(opacity * r)
        g = int(opacity * g)
        b = int(opacity * b)

        if r <= 255 and g <= 255 and b <= 255:
            self._button_activebackground = '#%02x%02x%02x' % (r, g, b)
        else:
            self._button_activebackground = '#%04x%04x%04x' % (r, g, b)

        self._button_background = button_background

        self.button_label = Label(self,
                                  text=button_text,
                                  background=button_background,
                                  foreground=button_foreground,
                                  font=button_font)
        if entry_font:
            self.button_label.configure(font=button_font)

        self.button_label.pack(side=LEFT, fill=Y, ipadx=button_ipadx)

        self.button_label.bind("<Enter>", self._state_active)
        self.button_label.bind("<Leave>", self._state_normal)

        self.button_label.bind("<ButtonRelease-1>", self._on_execute_command)
Ejemplo n.º 52
0
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.DEFAULT_SECTION = 'DEFAULT'

        self.grid()
        self.createWidgets()
Ejemplo n.º 53
0
    def __init__(self, window, picture, **kwargs) :
 
    
        style = Style()
        style.map('TCombobox', background=[('readonly',WIDGET_BACKGROUND)])


        # Window Background
        Frame.__init__(self, window, width=800, height=600, **kwargs)#,background=FRAME_BACKGROUND)
        self.pack(fill = BOTH, expand = YES)


        """
        # Greetings message
        self.message = Label(self, text = "Welcome in Super Radio Spectre Analyser!",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.message.grid(row=1,column=2,pady=5,sticky=N+E+W)     # The grid method places a widget in the window; pady is a margin around the widget
        """

        # Quit Button
        self.Oquit_button = Button(self, text="Quit", command=quit, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)  # command = self.quit defines the callback function
        self.Oquit_button.grid(row=8,column=5,pady=2,padx=2,sticky=N+E+W)   # padx is a margin around the widget and weight is a resizing coefficient


        # Compute Button
        self.Ocompute_button = Button(self, text="Compute", command=self.compute, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.Ocompute_button.grid(row=7,column=5,pady=2,padx=2,sticky=N+E+W)


        # Cancel flag
        self.cancel = mutex(False)


        # Spectrogram Image
        if os.path.exists(picture) :
            self.imagePath = str(picture)
        else :
            self.imagePath = "pictures/default.png"
        self.image_original = PIL.Image.open(self.imagePath)
        self.image_copy = self.image_original.copy()
        self.Oimage = PIL.ImageTk.PhotoImage(self.image_copy) # We use a label to display a picture
        self.Opic = Label(self,image=self.Oimage)
        self.Opic.grid(row=3,column=1,columnspan=3, rowspan=3, padx=10,sticky=N+W+S)
        self.Opic.bind('<Configure>',self.resize)
        self.resizeable = False # Security to avoid the resize function to get out of control
      

        # Carrier Signal Frequency
        self.frequency = "XXXXHz"
        self.Lfrequency = Label(self,text="Carrier signal's frequency: "+self.frequency,background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.Lfrequency.grid(row=6, column=2,pady=5,sticky=N+E+W)


        # Threshold       
        self.threshold = 3                                                 # In this, self.X is an attribute of the class, saving the current value
        self.Lthreshold = Label(self,text="Threshold",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)                     # self.Lx is the label of the corresponding object
        self.Lthreshold.grid(row=7,column=1,padx=2,sticky=S+E+W)
        self.Othreshold = Spinbox(self, from_=2, to=6, increment=1, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)    # self.Ox is the actual object
        self.Othreshold.grid(row=8,column=1,padx=2,sticky=N+E+W)


        # Margin
        self.margin = 12
        self.Lmargin = Label(self,text="Margin",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.Lmargin.grid(row=7,column=2,padx=2,sticky=S+E+W)   # Sticky allows to place a widget off-centered from its original position, according to the cardinal points
        self.Omargin = Spinbox(self, from_= 5, to = 25, increment = 5, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.Omargin.grid(row=8,column=2,padx=2,sticky=N+E+W)


        # Box Width
        self.boxWidth = 6
        self.LboxWidth = Label(self,text="Lines' Thickness",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.LboxWidth.grid(row=7,column=3,padx=2,sticky=S+E+W)
        self.OboxWidth = Spinbox(self, from_=4, to=10, increment = 2, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.OboxWidth.grid(row=8, column=3, padx=2, sticky=W+N+E)


        # Box Color
        self.color = [250,250,250] # RGB
        self.Lcolor = Label(self, text="Lines' Color",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.Lcolor.grid(row=7, column=4,padx=2,sticky=W+S+E)
        self.Ocolor = Combobox(self, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.Ocolor.grid(row=8, column=4,padx=2,sticky=N+E+W)
        self.Ocolor['values'] = ["blue","purple","red","orange","yellow","green","white","black"]


        # Spectrogram
        self.currentDir = "spectrograms/"
        self.file = ""
        #self.Lfile = Label(self, text = "Select a file",background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        #self.Lfile.grid(row=2,column=4,sticky=N+E+W)
        #self.Ofile = Combobox(self, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        #self.Ofile.grid(row=3,column=4,sticky=N+E+W)
        #self.Ofile['values'] = os.listdir("spectrograms/")
        self.Lfile = Label(self, text = "File selected: "+str(self.file),background=FRAME_BACKGROUND,foreground=WIDGET_FOREGROUND)
        self.Lfile.grid(row=2,column=4,columnspan = 2, sticky=N+E+W)
        self.Ofile = Button(self, text="Select a file", command=self.selectFile, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.Ofile.grid(row=3, column=5, sticky = N) 


        # Console-like messages
        self.console = ""
        self.Oconsole = Label(self,text=self.console, background=WIDGET_BACKGROUND, foreground=WIDGET_FOREGROUND)
        self.Oconsole.grid(row=4,column=4,sticky=N+E+W+S,columnspan=2,pady=5,padx=5)


        # Artificial Neuronal Network Choice
        self.ANN = "CNN"
        if os.path.exists("pictures/radioCNN.png") :
            self.ToggleButton = PIL.ImageTk.PhotoImage(PIL.Image.open("pictures/radioCNN.png").resize((56,23),PIL.Image.ANTIALIAS)) # We use a label to display a picture
            self.OANN = Label(self, background=FRAME_BACKGROUND, image=self.ToggleButton)
            self.OANN.grid(row=2,column=1,columnspan=1, padx=5, pady=5, sticky=N+W)
            self.OANN.bind('<Button-1>',self.toggleANN)



        # Resizing column coefficients
        self.columnconfigure(1,weight=1,pad=10)
        self.columnconfigure(2,weight=1,pad=10)
        self.columnconfigure(3,weight=1,pad=10)
        self.columnconfigure(4,weight=3,pad=10)
        self.columnconfigure(5,weight=3,pad=10)


        # Resizing row coefficients
        self.rowconfigure(1,weight=1)
        self.rowconfigure(2,weight=1)
        self.rowconfigure(3,weight=1)
        self.rowconfigure(4,weight=1)
        self.rowconfigure(5,weight=1)
        self.rowconfigure(6,weight=1)
        self.rowconfigure(7,weight=1)
        self.rowconfigure(8,weight=1)

       
        return
Ejemplo n.º 54
0
    def __init__(self,
                 master,
                 options,
                 width=20,
                 bordercolor="#cccccc",
                 foreground="black",
                 background="white",
                 activebackground="#2780E3",
                 activeforeground="white",
                 padx=15,
                 pady=7,
                 command=None):
        Frame.__init__(self,
                       master,
                       background=background,
                       highlightbackground=bordercolor,
                       highlightcolor=bordercolor,
                       highlightthickness=1,
                       bd=0)

        self._foreground = foreground
        self._background = background
        self._activebackground = activebackground
        self._activeforeground = activeforeground

        self._items = []

        index = 0
        for option in options:

            if option is None:
                Separator(self, orient=HORIZONTAL).pack(fill=X)
                continue

            if isinstance(option, basestring):
                test = option
                value = option
            else:
                text, value = option

            label_item = Label(self,
                               width=width,
                               text=text,
                               background=background,
                               foreground="black",
                               anchor=W,
                               padx=padx,
                               pady=pady)
            label_item.pack(fill=X)

            label_item.index = index
            label_item.value = value

            label_item.bind("<Enter>", self._on_enter_label_item)
            label_item.bind("<Leave>", self._on_leave_label_item)
            label_item.bind("<1>",
                            lambda event, index=index: self._on_click_item(
                                event.widget, index))
            self._items.append(label_item)

            index += 1

        self._actived_item = None
        self._command = command

        self.bind("<Up>", self._on_up)
        self.bind("<Down>", self._on_down)
        self.bind("<Return>", self._on_return)
Ejemplo n.º 55
0
 def __init__(self,
              master,
              file_mask,
              default_file,
              edit_height=None,
              user_onChange=None,
              rename_on_edit=0,
              font=None,
              coloring=True,
              allowNone=False,
              highlighter=None,
              directory='.'):
     '''
         file_mask: file mask (e.g. "*.foo") or list of file masks (e.g. ["*.foo", "*.abl"])
     '''
     self.master = master
     self.directory = directory
     self.user_onChange = user_onChange
     Frame.__init__(self, master)
     row = 0
     self.unmodified = True
     self.allowNone = allowNone
     self.file_extension = ""
     if type(file_mask) != list:
         file_mask = [file_mask]
     if "." in file_mask[0]:
         self.file_extension = file_mask[0][file_mask[0].rfind('.'):]
     # read filenames
     self.file_mask = file_mask
     self.updateList()
     # filename frame
     self.list_frame = Frame(self)
     self.list_frame.grid(row=row, column=0, sticky="WE")
     self.list_frame.columnconfigure(0, weight=1)
     # create list
     self.picked_name = StringVar(self)
     self.makelist()
     # refresh button
     self.refresh_button = Button(self.list_frame,
                                  text='<- refresh',
                                  command=self.refresh,
                                  height=1)
     self.refresh_button.grid(row=0, column=1, sticky='E')
     # save button
     self.save_button = Button(self.list_frame,
                               text="save",
                               command=self.save,
                               height=1)
     self.save_button.grid(row=0, column=2, sticky="E")
     # editor
     row += 1
     if coloring:
         self.editor = SyntaxHighlightingText(self,
                                              self.onEdit,
                                              highlighter=highlighter)
     else:
         self.editor = ScrolledText2(self, self.onEdit)
     if font != None:
         self.editor.configure(font=font)
     if edit_height is not None:
         self.editor.configure(height=edit_height)
     self.editor.grid(row=row, column=0, sticky="NEWS")
     self.rowconfigure(row, weight=1)
     self.columnconfigure(0, weight=1)
     # option to change filename on edit
     row += 1
     self.options_frame = Frame(self)
     self.options_frame.grid(row=row, column=0, sticky=W)
     self.rename_on_edit = IntVar()
     self.cb = Checkbutton(self.options_frame,
                           text="rename on edit",
                           variable=self.rename_on_edit)
     self.cb.pack(side=LEFT)
     self.cb.configure(command=self.onChangeRename)
     self.rename_on_edit.set(rename_on_edit)
     # filename frame
     row += 1
     self.filename_frame = Frame(self)
     self.filename_frame.grid(row=row, column=0, sticky="WE")
     self.filename_frame.columnconfigure(0, weight=1)
     # save as filename
     self.save_name = StringVar(self)
     self.save_edit = Entry(self.filename_frame,
                            textvariable=self.save_name)
     self.save_edit.grid(row=0, column=0, sticky="WE")
     self.save_name.trace("w", self.onSaveChange)
     # pick default if applicableButton
     self.select(default_file)
     self.row = row
Ejemplo n.º 56
0
 def __init__(self, parent, game):
     self.game = game
     Frame.__init__(self, parent)
     self.parent = parent
     self.row, self.col = -1, -1
     self.initUI()
Ejemplo n.º 57
0
 def __init__(self, master=None, **options):
     self.master = master
     Frame.__init__(self, master)
Ejemplo n.º 58
0
 def __init__(self, parent=None):  # constructor method
     Frame.__init__(self, parent)
     self.pack()
     widget = Button(self, text='Quit', command=self.quit)
     widget.pack(expand=YES, fill=BOTH, side=LEFT)
Ejemplo n.º 59
0
    def __init__(self, parent, options):
        if options == None:
            options = {}
        DefaultOptions = {
            'colorspace': 'RGB',
            'K': 2,
            'km_init': 'first',
            'verbose': False,
            'single_thr': 0.6,
            'metric': 'basic',
            'max_iter': 50
        }
        for op in DefaultOptions:
            if not op in options:
                options[op] = DefaultOptions[op]
        self.options = options
        self.K_ant = 0
        self.num_im = -1
        Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("TAGGING")

        self.F1 = Frame(parent, width=150, borderwidth=2, relief=GROOVE)
        self.F2 = Frame(parent, width=150, borderwidth=2, relief=GROOVE)
        self.F3 = Frame(parent)
        self.F4 = Frame(parent, borderwidth=2, relief=GROOVE)
        self.F5 = Frame(parent, borderwidth=2, relief=GROOVE)
        self.F1.pack(side=LEFT, fill=Y, pady=4, padx=4)
        self.F2.pack(side=LEFT, fill=Y, pady=4)
        self.F3.pack(side=TOP, expand=True, fill=BOTH, pady=4, padx=4)
        self.F4.pack(side=TOP, fill=BOTH, expand=0, padx=4)
        self.F5.pack(side=BOTTOM, fill=BOTH, expand=0, pady=4, padx=4)
        self.F1.pack_propagate(0)
        self.F2.pack_propagate(0)
        self.F3.pack_propagate(0)

        lbl = Label(self.F1, text="Groundtruth")
        lbl.grid(row=0, sticky=W)
        Frame(self.F1, borderwidth=1, relief=GROOVE, height=2).grid(row=1,
                                                                    sticky=W)

        lbl = Label(self.F2, text="Detected")
        lbl.grid(row=0, sticky=W, columnspan=2)
        Frame(self.F2, borderwidth=1, relief=GROOVE,
              height=2).grid(row=1, sticky=W, columnspan=2)

        self.filename = Button(self.F3,
                               text="filename",
                               command=self.ChooseFile)
        self.filename.pack(side=TOP, expand=0)

        #        #matplotlib setup
        #        plt.ion()
        self.figure = plt.figure(figsize=(2, 2), frameon=False)
        self.axes = self.figure.add_subplot(111)
        self.Canvas = FigureCanvasTkAgg(self.figure, master=self.F3)
        #        self.Canvas.show()
        self.Canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        plt.axis('off')

        b = Button(self.F4, text=" <<<10 ", command=self.PreviousFast)
        b.pack(side=LEFT, padx=(20, 2), pady=3)
        b = Button(self.F4, text=" <<1 ", command=self.Previous)
        b.pack(side=LEFT, pady=3)
        self.im_name = Button(self.F4,
                              text="image",
                              bd=0,
                              command=self.Results)
        self.im_name.pack(side=LEFT, expand=True)
        b = Button(self.F4, text=" 1>> ", command=self.Next)
        b.pack(side=LEFT)
        b = Button(self.F4, text=" 10>>> ", command=self.NextFast)
        b.pack(side=LEFT, padx=(2, 20))

        F51 = Frame(self.F5)
        F52 = Frame(self.F5)
        F53 = Frame(self.F5)
        F51.pack(fill=BOTH, expand=1, side=LEFT)
        Frame(self.F5, borderwidth=1, relief=GROOVE, width=2).pack(side=LEFT,
                                                                   fill=Y)
        F52.pack(fill=BOTH, expand=1, side=LEFT)
        Frame(self.F5, borderwidth=1, relief=GROOVE, width=2).pack(side=LEFT,
                                                                   fill=Y)
        F53.pack(fill=BOTH, expand=1, side=LEFT)

        Label(F51, text="Color space").pack()
        Frame(F51, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        Label(F52, text="K-Means").pack()
        Frame(F52, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        Label(F53, text="Labelling").pack()
        Frame(F53, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)

        self.ColorMode = StringVar()
        self.ColorMode.set(self.options[COLORSSPACE['key']])
        for text, mode in COLORSSPACE['options_gui']:
            b = Radiobutton(F51,
                            text=text,
                            variable=self.ColorMode,
                            value=mode,
                            command=self.Results)
            b.pack(anchor=W)

        Frame(F51, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        Label(F51, text="Grouping", padx=20).pack()
        Frame(F51, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        self.Group = BooleanVar()
        self.Group.set(True)
        b = Checkbutton(F51,
                        text='Group same label colors',
                        variable=self.Group,
                        command=self.Results)
        b.pack(anchor=W)

        F521 = Frame(F52)
        F522 = Frame(F52)

        F521.pack(fill=BOTH)
        F522.pack(fill=BOTH)
        #        F523 = Frame(F52)
        #        F523.pack(fill=BOTH)

        self.K = StringVar()
        self.K.set(self.options['K'])
        #        f = Frame(F52)
        #        f.pack(side=TOP, fill=BOTH,  expand=0)
        Label(F521, text="K : ").pack(side=LEFT)
        Entry(F521, textvariable=self.K, width=3,
              justify=CENTER).pack(side=LEFT, padx=4)
        #        Label(F52, text="Init", padx=20).pack(anchor=W)
        #        Frame(F521,borderwidth=1,relief=GROOVE,width=2).pack(side=RIGHT, fill=Y, padx=2)

        self.Fitting = StringVar()
        self.Fitting.set(self.options[FITTING['key']])
        #        f = Frame(F52)
        #        f.pack(side=RIGHT, fill=BOTH,  expand=0)
        for text, mode in FITTING['options_gui']:
            b = Radiobutton(F521,
                            text=text,
                            variable=self.Fitting,
                            value=mode,
                            command=self.Results)
            b.pack(anchor=W, padx=4)

        Frame(F522, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        Label(F522, text="Centroid Init", padx=20).pack()
        Frame(F522, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        #        IM = [('First points','first'),('Randomize', 'random'),('Distribtued','distributed'),('Other','Other')]

        self.KMInit = StringVar()
        self.KMInit.set(self.options[CENTROIDSINIT['key']])
        for text, mode in CENTROIDSINIT['options_gui']:
            b = Radiobutton(F522,
                            text=text,
                            variable=self.KMInit,
                            value=mode,
                            command=self.Results)
            b.pack(anchor=W)

        self.Thr = StringVar()
        self.Thr.set(self.options['single_thr'])
        f = Frame(F53)
        f.pack(side=TOP, fill=BOTH, expand=0)
        Label(f, text="single\nbasic   >\ncolor", justify=LEFT).pack(side=LEFT)
        Entry(f, textvariable=self.Thr, width=4,
              justify=CENTER).pack(side=LEFT)
        #        self.Synonymous = BooleanVar()
        #        self.Synonymous.set(self.options['synonyms'])
        #        b = Checkbutton(F53, text='Synonymous', variable=self.Synonymous, command=self.Results)
        #        b.pack(anchor=W)

        Frame(F53, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        Label(F53, text="Similarity Metric", padx=2).pack()
        Frame(F53, borderwidth=1, relief=GROOVE, height=2).pack(fill=X)
        self.Metric = StringVar()
        self.Metric.set(self.options[SIMILARITY['key']])
        for text, mode in SIMILARITY['options_gui']:
            b = Radiobutton(F53,
                            text=text,
                            variable=self.Metric,
                            value=mode,
                            command=self.Results)
            b.pack(anchor=W)
Ejemplo n.º 60
0
    def __init__(self,
                 master,
                 dir='.',
                 filesettings=None,
                 defaultname='*unknown{}',
                 importhook=None,
                 deletehook=None,
                 projecthook=None,
                 filecontenthook=None,
                 selectfilehook=None,
                 fileslisthook=None,
                 updatehook=None,
                 onchangehook=None):

        self.master = master

        Frame.__init__(self, master)

        self._dirty = False
        self._dirty_file_name = ''
        self._editor_dirty = False

        self.dir = dir
        self.fsettings = filesettings
        self.defaultname = defaultname

        # hooks
        self.import_hook = importhook
        self.delete_hook = deletehook
        self.save_project_hook = projecthook
        self.filecontent_hook = filecontenthook
        self.update_hook = updatehook
        self.select_file_hook = selectfilehook
        self.files_list_hook = fileslisthook
        self.onchange_hook = onchangehook

        Frame.__init__(self, master)
        row = 0
        self.columnconfigure(1, weight=2)

        self.selected_file = StringVar(master)
        files = []
        self.file_buffer = {}
        self.file_reload = True
        if len(files) == 0: files.append("")
        self.list_files = apply(OptionMenu,
                                (self, self.selected_file) + tuple(files))
        self.list_files.grid(row=row, column=1, sticky="NWE")
        self.selected_file.trace("w", self.select_file)

        # new file
        self.btn_newfile = Button(self, text='New', command=self.new_file)
        self.btn_newfile.grid(row=row, column=2, sticky="E")

        # import file
        self.btn_importfile = Button(self,
                                     text='Import',
                                     command=self.import_file)
        self.btn_importfile.grid(row=row, column=3, sticky="E")

        # delete file
        self.btn_delfile = Button(self,
                                  text='Delete',
                                  command=self.delete_file)
        self.btn_delfile.grid(row=row, column=4, sticky="E")

        # save button
        self.btn_update_file = Button(self,
                                      text='Save',
                                      command=self.save_file)
        self.btn_update_file.grid(row=row, column=6, sticky="E")

        # save as.. button
        self.btn_saveas_file = Button(self,
                                      text='Save as...',
                                      command=self.saveas_file)
        self.btn_saveas_file.grid(row=row, column=7, sticky="E")

        # editor
        row += 1
        self.editor = SyntaxHighlightingText(
            self, change_hook=self.onchange_filecontent)
        self.editor.grid(row=row, column=1, columnspan=7, sticky="NWES")
        self.rowconfigure(row, weight=1)