def _init_components(self):
        self._panes = PanedWindow(self, orient='horizontal', sashrelief="raised")
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes, padx=10, pady=5)
        self._right_pane = PanedWindow(self._panes)
        self._panes.add(self._left_pane, sticky='n')
        self._panes.add(self._right_pane)

        self._group_select = GroupSelect(self._left_pane)
        self._group_select.pack(expand=True, fill='x')

        # spacer
        Frame(self._left_pane, height=10).pack()

        graph_controls = LabelFrame(self._left_pane, text="Graph options", padx=10, pady=5)
        graph_controls.columnconfigure(1, weight=1)
        graph_controls.pack(expand=True, fill='x')

        self._show_graph_checkbutton = CheckBox(graph_controls, text='Show graph')
        self._show_graph_checkbutton.select()
        self._show_graph_checkbutton.grid(row=0, columnspan=2, sticky='w')

        Label(graph_controls, text='Algorithm').grid(row=1, sticky='w')
        self._graph_type = OptionList(graph_controls, values=MainWindow.GRAPH_TYPES.keys())
        self._graph_type.config(width=15)
        self._graph_type.grid(row=1, column=1, sticky='we')

        # spacer
        Frame(self._left_pane, height=10).pack()

        self._go_button = Button(self._left_pane, text='Go', command=self._go)
        self._go_button.pack()
    def initGUI(self):
        frame = Frame(self, width=630, height=500)
        self.panel = PanedWindow(frame, orient=HORIZONTAL)

        self.LeftFrame(self.panel)
        self.RightFrame(self.panel)
        self.panel.add(self.LFrame)
        self.panel.add(self.RFrame)
        self.panel.pack()
        frame.pack()
Example #3
0
    def _init_components(self):
        self._panes = PanedWindow(self,
                                  orient='horizontal',
                                  sashrelief="raised")
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes)
        self._right_pane = PanedWindow(self._panes)
        self._panes.add(self._left_pane, sticky='n')
        self._panes.add(self._right_pane)

        self._group_select = GroupSelect(self._left_pane)
        self._group_select.pack(expand=True, fill='x')

        self._show_graph_checkbutton = CheckBox(self._left_pane,
                                                text='Show graph')
        self._show_graph_checkbutton.select()
        self._show_graph_checkbutton.pack()

        self._go_button = Button(self._left_pane, text='Go', command=self._go)
        self._go_button.pack()
 def printInfoAnt(self, i):
     self.frameAnt = PanedWindow(self.FrameInfo, orient=VERTICAL)
     t_Ant = Label(self.frameAnt, text="Information Ant : %d" % (i))
     (t_brain, t_energie, t_acide) = self.getInfoAnt(i)
     a_b = Label(self.frameAnt, text=t_brain)
     a_e = Label(self.frameAnt, text=t_energie)
     a_a = Label(self.frameAnt, text=t_acide)
     t_Ant.pack(side=TOP)
     self.frameAnt.add(t_Ant)
     self.frameAnt.add(a_b)
     self.frameAnt.add(a_e)
     self.frameAnt.add(a_a)
     self.frameAnt.pack()
Example #5
0
 def add_pane(self):
     master = PanedWindow(bg=BACKGROUND_COLOR)
     master.pack(side=LEFT)
     master.propagate(0)
     canvas = self.get_map().get_canvas()
     hbar = Scrollbar(master, orient=HORIZONTAL)
     hbar.pack(side=BOTTOM, fill=X)
     hbar.config(command=canvas.xview)
     vbar = Scrollbar(master, orient=VERTICAL)
     vbar.pack(side=RIGHT, fill=Y)
     vbar.config(command=canvas.yview)
     canvas.config(xscrollcommand=hbar.set, yscrollcommand=vbar.set)
     canvas.pack(side=LEFT, expand=True, fill=BOTH)
     master.config(width=PANE_W, height=PANE_H)
     master.add(canvas)
 def printTurn(self):
     frameS = PanedWindow(self.FrameInfo, orient=HORIZONTAL)
     turns = Label(frameS, text="Tour :")
     self.var.set(str(self.selectTurn))
     self.Spin_T = Spinbox(frameS,
                           values=self.turns.keys(),
                           command=self.updateSpin_turn,
                           textvariable=self.var)
     self.Spin_T.bind('<Return>', self.validateTurn)
     turns.pack()
     self.Spin_T.pack()
     frameS.add(turns)
     frameS.add(self.Spin_T)
     frameS.pack()
     self.frameT = frameS
Example #7
0
    def _init_components(self):
        self._panes = PanedWindow(self, orient='horizontal',
            sashrelief='raised')
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes, padx=2, pady=2)
        self._right_pane = Frame(self._panes)
        self._panes.add(self._left_pane, width=500)
        self._panes.add(self._right_pane)

        # group name
        group_name_pane = LabelFrame(self._left_pane, text="Group")
        group_name_pane.pack(fill='x')

        self._group_name = GroupNameLabel(group_name_pane, self._group)
        self._group_name.pack(expand=True, fill='both')

        # group order
        group_order_pane = LabelFrame(self._left_pane, text="Order")
        group_order_pane.pack(fill='x')

        self._group_order = IntegerContainer(group_order_pane,
            integer=self._group.order())
        self._group_order.pack(expand=True, fill='both')

        # apex
        self._apex_pane = LabelFrame(self._left_pane, text="Apex")
        self._apex_pane.pack(expand=True, fill='both')

        self._apex_container = ApexListContainer(self._apex_pane,
            apex=self._group.apex())
        self._apex_container.pack(expand=True, fill='both')

        self._show_graph_button = Button(self._right_pane, text='Show graph',
            command=self._show_graph_canvas)
        self._graph_canvas = None
        if self._show_graph:
            self._show_graph_canvas()
        else:
            self._show_graph_button.pack()
Example #8
0
    def BuildMainFrame(self):
        from Tkinter import Menu, IntVar, StringVar, Toplevel, Listbox, Frame, PanedWindow, Text, Scrollbar, Entry
        from Tkinter import X, N, S, W, E, VERTICAL, TOP, END, DISABLED, RAISED

        menu = Menu(self.master, activeborderwidth=0, bd=0)
        self.master.config(menu=menu)

        filemenu = Menu(menu, tearoff=0, bd=1, activeborderwidth=0)
        menu.add_cascade(label="File", underline=0, menu=filemenu)
        filemenu.add_command(label="New",
                             accelerator='Ctrl+N',
                             command=self.NewCommand)
        filemenu.add_command(label="Open...",
                             accelerator='Ctrl+O',
                             command=self.OpenCommand)
        filemenu.add_command(label="Save as...",
                             accelerator='Ctrl+S',
                             command=self.SaveCommand)
        filemenu.add_separator()
        filemenu.add_command(label="Quit",
                             accelerator='Ctrl+Q',
                             command=self.QuitCommand)

        self.log_on = IntVar()
        self.log_on.set(1)

        self.output_to_file = StringVar()
        self.output_to_file.set('n')

        scriptmenu = Menu(menu, tearoff=0, bd=1, activeborderwidth=0)
        modulenames = ['vmtkscripts']
        for modulename in modulenames:
            scriptsubmenu = self.BuildScriptMenu(menu, modulename)
            if scriptsubmenu:
                scriptmenu.add_cascade(label=modulename, menu=scriptsubmenu)

        editmenu = Menu(menu, tearoff=0, bd=1, activeborderwidth=0)
        menu.add_cascade(label="Edit", underline=0, menu=editmenu)
        editmenu.add_cascade(label="Insert script", menu=scriptmenu)
        editmenu.add_command(label="Insert file name",
                             accelerator='Ctrl+F',
                             command=self.InsertFileName)
        editmenu.add_separator()
        editmenu.add_command(label="Clear input",
                             command=self.ClearInputCommand)
        editmenu.add_command(label="Clear output",
                             command=self.ClearOutputCommand)
        editmenu.add_command(label="Clear all", command=self.ClearAllCommand)
        editmenu.add_separator()
        editmenu.add_checkbutton(label="Log", variable=self.log_on)
        editmenu.add_separator()
        editmenu.add_radiobutton(label="No output to file",
                                 variable=self.output_to_file,
                                 value='n')
        editmenu.add_radiobutton(label="Write output to file",
                                 variable=self.output_to_file,
                                 value='w')
        editmenu.add_radiobutton(label="Append output to file",
                                 variable=self.output_to_file,
                                 value='a')
        editmenu.add_command(label="Output file...",
                             command=self.OutputFileCommand)

        runmenu = Menu(menu, tearoff=0, bd=1, activeborderwidth=0)
        menu.add_cascade(label="Run", underline=0, menu=runmenu)
        runmenu.add_command(label="Run all", command=self.RunAllCommand)
        runmenu.add_command(label="Run current line",
                            command=self.RunLineCommand)
        runmenu.add_command(label="Run selection",
                            command=self.RunSelectionCommand)

        helpmenu = Menu(menu, tearoff=0, bd=1, activeborderwidth=0)
        menu.add_cascade(label="Help", underline=0, menu=helpmenu)
        helpmenu.add_command(label="Help",
                             underline=0,
                             accelerator='F1',
                             command=self.ShowHelpCommand)
        helpmenu.add_command(label="About",
                             underline=0,
                             command=self.AboutCommand)

        self.master.bind("<Control-KeyPress-q>", self.QuitHandler)
        self.master.bind("<Control-KeyPress-n>", self.NewHandler)
        self.master.bind("<Control-KeyPress-o>", self.OpenHandler)
        self.master.bind("<Control-KeyPress-s>", self.SaveHandler)
        self.master.bind("<Control-KeyPress-f>", self.InsertFileNameHandler)
        self.master.bind("<KeyPress-F1>", self.ShowHelpHandler)
        self.master.bind("<KeyPress>", self.KeyPressHandler)

        self.wordIndex = ['1.0', '1.0']

        self.suggestionswindow = Toplevel(bg='#ffffff',
                                          bd=0,
                                          height=50,
                                          width=600,
                                          highlightthickness=0,
                                          takefocus=True)
        self.suggestionswindow.overrideredirect(1)
        self.suggestionslist = Listbox(self.suggestionswindow,
                                       bg='#ffffff',
                                       bd=1,
                                       fg='#336699',
                                       activestyle='none',
                                       highlightthickness=0,
                                       height=9)
        self.suggestionslist.insert(END, "foo")
        self.suggestionslist.pack(side=TOP, fill=X)
        self.suggestionswindow.bind("<KeyPress>", self.TopKeyPressHandler)
        self.suggestionswindow.withdraw()

        self.master.rowconfigure(0, weight=1)
        self.master.columnconfigure(0, weight=1)
        content = Frame(self.master, bd=0, padx=2, pady=2)
        content.grid(row=0, column=0, sticky=N + S + W + E)
        content.rowconfigure(0, weight=1, minsize=50)
        content.rowconfigure(1, weight=0)
        content.columnconfigure(0, weight=1)

        panes = PanedWindow(content,
                            orient=VERTICAL,
                            bd=1,
                            sashwidth=8,
                            sashpad=0,
                            sashrelief=RAISED,
                            showhandle=True)
        panes.grid(row=0, column=0, sticky=N + S + W + E)

        frame1 = Frame(panes, bd=0)
        frame1.grid(row=0, column=0, sticky=N + S + W + E)
        frame1.columnconfigure(0, weight=1)
        frame1.columnconfigure(1, weight=0)
        frame1.rowconfigure(0, weight=1)

        panes.add(frame1, height=300, minsize=20)

        frame2 = Frame(panes, bd=0)
        frame2.grid(row=1, column=0, sticky=N + S + W + E)
        frame2.columnconfigure(0, weight=1)
        frame2.columnconfigure(1, weight=0)
        frame2.rowconfigure(0, weight=1)

        panes.add(frame2, minsize=20)

        self.text_input = Text(frame1,
                               bg='#ffffff',
                               bd=1,
                               highlightthickness=0)

        self.text_input.bind("<KeyPress>", self.KeyPressHandler)
        self.text_input.bind("<Button-3>", self.PopupHandler)
        self.text_input.bind("<Control-Return>", self.RunKeyboardHandler)

        self.input_scrollbar = Scrollbar(frame1,
                                         orient=VERTICAL,
                                         command=self.text_input.yview)
        self.text_input["yscrollcommand"] = self.input_scrollbar.set

        self.text_output = Text(frame2,
                                state=DISABLED,
                                bd=1,
                                bg='#ffffff',
                                highlightthickness=0)

        self.output_scrollbar = Scrollbar(frame2,
                                          orient=VERTICAL,
                                          command=self.text_output.yview)
        self.text_output["yscrollcommand"] = self.output_scrollbar.set

        self.text_entry = Entry(content,
                                bd=1,
                                bg='#ffffff',
                                state=DISABLED,
                                highlightthickness=0)

        self.text_input.focus_set()

        self.text_input.grid(row=0, column=0, sticky=N + S + W + E)
        self.input_scrollbar.grid(row=0, column=1, sticky=N + S + W + E)
        self.text_output.grid(row=0, column=0, sticky=N + S + W + E)
        self.output_scrollbar.grid(row=0, column=1, sticky=N + S + W + E)
        self.text_entry.grid(row=1, column=0, sticky=N + S + W + E)

        self.popupmenu = Menu(self.text_input, tearoff=1, bd=0)
        self.popupmenu.add_command(label="Context help",
                                   command=self.ShowHelpCommand)
        self.popupmenu.add_cascade(label="Insert script", menu=scriptmenu)
        self.popupmenu.add_command(label="Insert file name...",
                                   command=self.InsertFileName)
        self.popupmenu.add_separator()
        self.popupmenu.add_command(label="Run all", command=self.RunAllCommand)
        self.popupmenu.add_command(label="Run current line",
                                   command=self.RunLineCommand)
        self.popupmenu.add_command(label="Run selection",
                                   command=self.RunSelectionCommand)

        self.output_stream = TkPadOutputStream(self.text_output)
        self.input_stream = TkPadInputStream(self.text_entry,
                                             self.output_stream)
Example #9
0
    def __init__(self, *args, **kwargs):
        '''
nodeName:   The name of this node. Usually set by ModelNode.__setattr__ automatically.
figureMeta: Meta information of figure.
The rest parameters are passed to PanedWindow.__init__.
'''
        nodeName = kwargs.pop('nodeName', '')
        # lock

        super(FigureBook, self).__init__(nodeName=nodeName)

        figureMeta = None if 'figureMeta' not in kwargs \
            else kwargs.pop('figureMeta')
        kwargs['orient'] = HORIZONTAL

        panedWindow = PanedWindow(*args, **kwargs)

        panedWindow.config(sashwidth=4, sashrelief=GROOVE, bg='forestgreen')

        #        figureTabsStyle = Style()
        #        figureTabsStyle.configure('Figure.TNotebook', tabposition='sw')
        #        figureTabs    = Notebook(panedWindow, style='Figure.TNotebook')
        figureTabs = Notebook(panedWindow)

        self.figureTabs = figureTabs
        figureTabs.bind('<<NotebookTabChanged>>', self.onTabChange)
        self.lockAttribute('figureTabs')

        if figureMeta:
            self.makeFigures(figureMeta)

        self.lockElements()

        panedWindow.add(figureTabs, stretch='always')

        listPan = PanedWindow(panedWindow, orient=VERTICAL)
        listPan.config(sashwidth=4, sashrelief=GROOVE, bg='forestgreen')
        panedWindow.add(listPan, stretch='never')

        listFrm = Frame(listPan)
        listPan.add(listFrm, stretch='always')
        Label(listFrm, text='Curves', bg='#b5d6b0').pack(side=TOP, fill=X)
        self.__list = ScrolledList(listFrm, relief=GROOVE)
        self.__list.listConfig(width=20)
        self.__list.listClick = self.onListClick
        self.__list.pack(fill=BOTH, expand=YES)

        listFrm = Frame(listPan)
        listPan.add(listFrm, stretch='never')
        Label(listFrm, text='Indicators', bg='#b5d6b0').pack(side=TOP, fill=X)
        self.__indicatorListbox = ScrolledList(listFrm, relief=GROOVE)
        self.__indicatorListbox.listConfig(width=20)
        self.__indicatorListbox.pack(fill=BOTH, expand=YES)

        with self.attributeLock:
            setMultiAttr(
                self,
                panedWindow=panedWindow,
                gridGroupObserver=self.GridGroupObserver(self),
                axisGroupObserver=self.AxisGroupObserver(self),
                clearGroupObserver=self.ClearGroupObserver(self),
                labelGroupObserver=self.LabelGroupObserver(self),
                indicatorGroupObserver=self.IndicatorGroupObserver(self),
                dataFigureObserver=self.DataFigureObserver(self),
                dataPool=[])
Example #10
0
    def refreshWidget(self):
        #print "refresh"
        self.card_win.pack_forget()

        #Card window
        self.card_win = PanedWindow(self.card_win.master, orient=VERTICAL)
        self.card_win.pack(side=TOP, expand=True, fill=BOTH, pady=2, padx=2)

        #Create the name zone
        name_zone = PanedWindow(self.card_win, orient=HORIZONTAL)
        name = StringVar()
        name.set(self.name)
        from deck_creation import blocked_creature

        def modifName(*args):
            old = self.name in blocked_creature
            self.name = name.get()
            if old or self.name in blocked_creature:
                self.refreshWidget()

        name.trace("w", modifName)
        name_wid = Entry(name_zone, width=30, textvariable=name)
        name_wid.pack()
        name_zone.add(name_wid)
        #Create the cost ad star stringvar
        #print int(floor(self.getCost()))
        self.cost = StringVar()
        self.stars = StringVar()
        cost_wid = Label(None,
                         textvariable=self.cost,
                         background='red',
                         width=5,
                         anchor=W)
        star_wid = Label(None,
                         textvariable=self.stars,
                         background='blue',
                         anchor=E)
        self.cost.set(str(int(floor(self.getCost()))))
        self.stars.set("*" * self.getStars())
        #Add them in name zone
        name_zone.add(cost_wid)
        name_zone.add(star_wid)

        #Create an Image Zone
        image_zone = Button(self.card_win, command=self.choosePhoto)
        if hasattr(self, "photofile") and self.photofile:
            print "Image: ", self.photofile
            try:
                img = Image.open(self.photofile)
            except:
                decomp = self.photofile.split('/')
                for i in range(1, 6):
                    try:
                        fname = "/".join(decomp[-i:])
                        print "try to open", fname
                        img = Image.open(fname)
                        self.photofile = fname
                        break
                    except:
                        self.photofile = None
        if self.photofile:
            w, h = img.size
            if w > 300 or h > 200:
                img = img.resize((w / 2, h / 2), Image.LINEAR)
            image_zone.image = ImageTk.PhotoImage(img)
            image_zone.config(image=image_zone.image)
            #print "IMAGE CHANGED"
        else:
            from os import path
            fname = self.name.replace(" ", "_")
            if path.isfile("Cards/" + fname + ".png"):
                image_zone.config(text='image can be taken from\n' + "Cards/" +
                                  fname + ".png",
                                  background='white',
                                  anchor=CENTER)
            else:
                image_zone.config(text='clic to choose image',
                                  background='white',
                                  anchor=CENTER)

        image_zone.pack

        # POWER ZONE
        power_zone = PanedWindow(self.card_win, orient=VERTICAL)

        #fenetre=self.card_win.master
        def removePowerCreator(px):
            def removePower(*args):
                #print 'avant',list_pow
                self.bonus.remove(px)
                #print 'apres',list_pow
                #self.card_win.pack_forget()
                self.refreshWidget()

            return removePower

        for p in self.bonus:
            powline = PanedWindow(self.card_win, orient=HORIZONTAL)
            pow_wid = p.initWidget(powline)
            powline.add(pow_wid)
            removepow = Button(powline,
                               text="X",
                               command=removePowerCreator(p),
                               anchor=E)
            removepow.pack()
            powline.add(removepow)
            power_zone.add(powline)

        def addPower(*args):
            name = addBonus.get()
            print "added :", name
            import cardPowers
            self.bonus += [eval('cardPowers.' + name + '()')]
            self.bonus[-1].parent = self.bonus
            self.bonus[-1].card = self
            #self.card_win.pack_forget()
            self.refreshWidget()

        #Add bonus Option menu
        addBonus = StringVar(power_zone)
        addBonus.set("add bonus")  # default value
        if not self.pv: addBonus_wid = getSpellMenu(power_zone, addBonus)
        else: addBonus_wid = getBonusMenu(power_zone, addBonus)
        addBonus.trace('w', addPower)
        if self.pv > 0 or len(self.bonus) == 0:
            addBonus_wid.pack()
            #Add this to power zone
            power_zone.add(addBonus_wid)

        #Create save zone
        save_zone = PanedWindow(self.card_win, orient=HORIZONTAL)
        lv = int(localopen("progression", "r").read())
        if self.monster_type != "all" and not (lv < 8 and self.name
                                               in blocked_creature):
            save_wid = Button(save_zone, text="Save", command=self.postAndSave)
        elif self.monster_type != "all":
            save_wid = Button(save_zone,
                              text="creature in campaign",
                              command=None)
        else:
            save_wid = Button(save_zone, text="nead type", command=None)
        save_wid.pack()
        #Create the open button
        save_zone.pack()
        if Card.monster_list.keys():
            self.opening = StringVar(save_zone)
            self.opening.set("Open")
            choice = Card.monster_list.keys()
            choice.sort()
            #print all_monsters.keys()
            open_wid = OptionMenu(save_zone, self.opening, *choice)
            self.opening.trace('w', self.Open)
            open_wid.pack()
            save_zone.add(open_wid)

        if Card.monster_list.keys():
            self.delete = StringVar(save_zone)
            self.delete.set("Delete")
            choice = Card.monster_list.keys()
            choice.sort()
            delete_wid = OptionMenu(save_zone, self.delete, *choice)
            self.delete.trace('w', self.clicDelete)
            delete_wid.pack()
            save_zone.add(delete_wid)

        #Create the type button
        self.category = StringVar(save_zone)
        self.category.set(self.monster_type)
        choice = [
            file2name(t, "_monsters.sav")
            for t in glob.glob("CardFiles/*_monsters.sav")
        ]
        if "recup" in choice:
            choice.remove("recup")
        #print all_monsters.keys()
        category_wid = OptionMenu(save_zone, self.category, *choice)
        self.category.trace('w', self.setFile)

        category_wid.pack()

        #Add it to save zone
        save_zone.add(save_wid)
        save_zone.add(category_wid)

        #Create a new Strength zone for att and pv
        strength_zone = PanedWindow(self.card_win, orient=HORIZONTAL)
        att = StringVar()
        att.set(str(self.att))
        pv = StringVar()
        pv.set(str(self.pv))

        def modifiedAttPv(*args):
            print "modifiedAttPv"
            self.pv = int(pv.get())
            if self.pv < 1 and self.is_spell == False:
                if len(self.bonus) == 0:
                    self.is_spell = True
                    self.refreshWidget()
                else:
                    self.pv = 1
                    self.refreshWidget()
            if self.pv > 0 and self.is_spell == True:
                if len(self.bonus) == 0:
                    self.is_spell = False
                    self.refreshWidget()
                else:
                    self.pv = 0
                    self.refreshWidget()
            self.att = int(att.get())
            self.getCost()

        att_wid = Spinbox(strength_zone,
                          from_=0,
                          to=1000,
                          textvariable=att,
                          command=modifiedAttPv)
        att_wid.pack()
        strength_zone.add(att_wid)
        strength_zone.add(
            Label(strength_zone,
                  text='       ',
                  background='white',
                  anchor=CENTER))
        pv_wid = Spinbox(strength_zone,
                         from_=0,
                         to=1000,
                         textvariable=pv,
                         command=modifiedAttPv)
        pv_wid.pack()
        strength_zone.add(pv_wid)

        #Put it all in window
        self.card_win.add(name_zone)
        self.card_win.add(image_zone)
        self.card_win.add(power_zone)
        self.card_win.add(strength_zone)
        self.card_win.add(save_zone)

        self.card_win.pack()
Example #11
0
 def initWidget(self, fenetre):
     #print "init"
     self.card_win = PanedWindow(fenetre, orient=VERTICAL)
     fenetre.child = self
     self.refreshWidget()
    def _init_components(self):
        self._panes = PanedWindow(self,
                                  orient='horizontal',
                                  sashrelief='raised')
        self._panes.pack(expand=True, fill='both')

        self._left_pane = Frame(self._panes, padx=2, pady=2)
        self._right_pane = Frame(self._panes)
        self._panes.add(self._left_pane, width=250)
        self._panes.add(self._right_pane)

        # group name
        group_name_pane = LabelFrame(self._left_pane,
                                     text="Group",
                                     padx=10,
                                     pady=5)
        group_name_pane.pack(fill='x')

        self._group_name = GroupNameLabel(group_name_pane, self._group)
        self._group_name.pack(expand=True, fill='both')

        # group order
        group_order_pane = LabelFrame(self._left_pane,
                                      text="Order",
                                      padx=10,
                                      pady=5)
        group_order_pane.pack(fill='x')

        self._group_order = IntegerContainer(group_order_pane,
                                             integer=self._group.order())
        self._group_order.pack(expand=True, fill='both')

        # apex
        self._apex_pane = LabelFrame(self._left_pane,
                                     text="Apex",
                                     padx=10,
                                     pady=5)
        self._apex_pane.pack(expand=True, fill='both')

        self._apex_container = ApexListContainer(self._apex_pane,
                                                 apex=self._group.apex())
        self._apex_container.pack(expand=True, fill='both')

        # graph controls
        cocliques_frame = LabelFrame(self._left_pane,
                                     text="Cocliques",
                                     padx=10,
                                     pady=5)
        cocliques_frame.pack(fill='x')

        self._cocliques_button = Button(cocliques_frame,
                                        text="Calculate",
                                        command=self._show_cocliques)
        self._cocliques_button.pack(anchor='nw')

        self._cocliques_container = ListContainer(cocliques_frame)
        self._cocliques_list = Listbox(self._cocliques_container)
        self._cocliques_container.set_listbox(self._cocliques_list)

        # Button(graph_controls, text='Group equivalent vertices').pack(anchor='nw')

        # this is a button that show up instead of graph canvas if we uncheck 'Show graph' checkbox.
        self._show_graph_button = Button(self._right_pane,
                                         text='Show graph',
                                         command=self._show_graph_canvas)
        self._graph_canvas = None
        if self._show_graph:
            self._show_graph_canvas()
        else:
            self._show_graph_button.pack()
Example #13
0
    def __init__(self, root):
        self.root = root

        # Radio action buttons
        self.action = None
        self.sgmap_single_btn, self.krn_lib_btn, self.multi_map_btn = None, None, None

        self.file_log_var = StringVar()
        self.csv_file_var = StringVar()
        self.krn_folder_var = StringVar()
        self.output_folder_var = StringVar()
        self.sgmap_folder_var = StringVar()

        self.krn_ent_var = StringVar()
        self.krn_var, self.hem_var = IntVar(), IntVar()
        self.img, self.cdiag = None, None
        self.lat_lbl, self.lat_entry = None, None
        self.k_lbl, self.k_entry = None, None
        self.zen_lbl, self.zen_entry = None, None
        self.azi_lbl, self.azi_entry = None, None
        self.krn_lvl, self.krn_entry, self.krn_btn = None, None, None
        self.txt_redir, self.prg_log = None, None
        self.map_btn, self.gen_krn_btn = None, None

        # Sets window title, size, and icon on screen.
        self.root.title("Skyglow Estimation Toolbox (SET)")
        self.root.geometry('%dx%d+%d+%d' %
                           (constants.SW * 0.75, constants.SH * 0.75, 25, 25))
        self.root.iconbitmap(os.path.join(os.getcwd(), constants.ICO))
        self.root.resizable(False, False)
        self.root.update_idletasks()

        # Creates three paned windows for the main screen.
        base = PanedWindow()
        base.pack(fill=BOTH, expand=1)
        sub1 = PanedWindow(base,
                           orient=VERTICAL,
                           height=self.root.winfo_height() * 3 / 4)
        base.add(sub1)
        sub2 = PanedWindow(sub1,
                           orient=HORIZONTAL,
                           height=self.root.winfo_height() / 5)
        sub1.add(sub2)

        # Creates frame for holding inputs.
        self.input_frame = Frame(sub2)
        sub2.add(self.input_frame)

        # Creates frame for bottom half of main screen.
        self.img_frame = Frame(sub1, bd=2, bg='white', relief="sunken")
        sub1.add(self.img_frame)

        # Creates canvas for displaying images.
        self.img_canvas = Canvas(self.img_frame,
                                 bd=2,
                                 relief="groove",
                                 width=constants.SW * 0.6,
                                 height=self.root.winfo_height() * 3 / 4 * 0.9)
        self.img_canvas.place(relx=.5, rely=.5, anchor=CENTER)

        # Creates help button for link to documentation, instructions, and about.
        self.help_btn = Menubutton(self.input_frame,
                                   text="Help",
                                   relief="raised",
                                   bd=2,
                                   width=8,
                                   pady=1)
        #self.help_btn.place(relx=1, rely=0, anchor=NE)
        self.help_btn.grid(column=4, columnspan=1, row=0)
        self.help_btn_menu = Menu(self.help_btn, tearoff=0)
        doc = 'https://github.com/NASA-DEVELOP'
        self.help_btn_menu.add_command(label="Documentation",
                                       command=lambda: self.open_url(doc))
        self.help_btn_menu.add_command(label="Instructions",
                                       command=self.instructions)
        self.help_btn_menu.add_separator()
        self.help_btn_menu.add_command(label="About", command=self.about)
        self.help_btn["menu"] = self.help_btn_menu
Example #14
0
    def __init__(self, r):
        self.load_img = ImageTk.PhotoImage(file=PATH + '/ico/load.png')
        self.save_img = ImageTk.PhotoImage(file=PATH + '/ico/save.png')
        self.__root = r  # Root of program
        self.__file = ''  # Current file in use
        self.xrange = self.yrange = (0, 1000
                                     )  # X and Y range for scrolling plot
        self.panx = self.pany = 0  # Pan values for shifting map
        self.plot = Plot.baseplot  # Current selected plot
        self.__label_file_dialog = None
        self.new_file_flag = False
        self.option_menu = None
        self.shape_var = StringVar()
        self.__data_block = LoadData('Empty')
        self.plot_type = IntVar()

        self.width = self.__root.winfo_screenwidth()
        self.height = self.__root.winfo_screenheight()

        logger.info('Screen resolution: ' + str(self.width) + 'x' +
                    str(self.height))

        base_pane = PanedWindow()
        base_pane.pack(fill=BOTH, expand=1)
        sectioned_pane = PanedWindow(orient=VERTICAL)
        base_pane.add(sectioned_pane)
        top_paned_window = PanedWindow(sectioned_pane, orient=HORIZONTAL)
        sectioned_pane.add(top_paned_window)

        # Frame to hold dialog for browsing files
        self.__dialog_frame = Frame(top_paned_window)
        self.__dialog_frame.pack(side=LEFT)
        self.__dialog_shape_frame = Frame(top_paned_window)
        self.__dialog_shape_frame.pack(side=RIGHT)

        # Bottom half the screen
        bottom_paned_window = PanedWindow(sectioned_pane)
        sectioned_pane.add(bottom_paned_window)

        # The frame on which we will set out canvas for drawing etc.
        self.__drawplot_frame = Frame(bottom_paned_window,
                                      width=constants.WIDTH,
                                      height=constants.HEIGHT)

        # Matplotlib backend objects
        self.__parent_fig = Figure(figsize=(16, 11))
        self.__fig = self.__parent_fig.add_subplot(1, 1, 1)
        self.__parent_fig.set_tight_layout(True)
        self.__drawplot_canvas = FigureCanvasTkAgg(
            self.__parent_fig, master=self.__drawplot_frame)
        # Create ToolsWindow class and pass itself + the root
        logger.info('Creating ToolsWindow')
        self.__child = ToolsWindow(self.__drawplot_canvas, self, r)
        logger.info('Creating ShapeManager')
        self.__shapemanager = ShapeManager(self.__fig, self.__drawplot_canvas,
                                           self)
        logger.info('Binding matplotlib backend to canvas and frame')
        self.__toolbar = NavigationToolbar2CALIPSO(
            self, self.__drawplot_canvas, self.__child.coordinate_frame)

        # pack and display canvas
        self.__drawplot_canvas.get_tk_widget().pack(side=TOP,
                                                    fill=BOTH,
                                                    expand=1)
        self.__drawplot_frame.pack()
        self.__root.protocol('WM_DELETE_WINDOW', self.close)
Example #15
0
    def __init__(self, master, max_num_features, num_frames, mser_image):
        Toplevel.__init__(self, master)

        self.protocol('WM_DELETE_WINDOW', self.withdraw)

        self.notebook = ttk.Notebook(self)
        frame_feats = ttk.Frame(self.notebook)
        frame_forest = ttk.Frame(self.notebook)
        frame_mser = ttk.Frame(self.notebook)
        frame_other = ttk.Frame(self.notebook)
        self.notebook.add(frame_feats, text="Features ")
        self.notebook.add(frame_forest, text=" Forest  ")
        self.notebook.add(frame_mser, text=" MSER  ")
        self.notebook.add(frame_other, text=" Other  ")

        self.max_num_feats = max_num_features
        self.selection = None

        self.mser_image = mser_image

        rand_row = random.randint(1, 512 - 200)
        rand_col = random.randint(1, 512 - 110)
        self.mser_area = mser_image[rand_row:rand_row + 180,
                                    rand_col:rand_col + 100]

        # read images from icons folder
        self.hf0_img = PhotoImage(file="./icons/hf0.gif")
        self.hf1_img = PhotoImage(file="./icons/hf1.gif")
        self.hf2_img = PhotoImage(file="./icons/hf2.gif")
        self.hf3_img = PhotoImage(file="./icons/hf3.gif")
        self.hf4_img = PhotoImage(file="./icons/hf4.gif")
        self.hf5_img = PhotoImage(file="./icons/hf5.gif")

        self.features_vars = list()
        for i in range(max_num_features):
            self.features_vars.append(IntVar())

        Label(frame_feats,
              text="Patch size (" + u"\N{GREEK SMALL LETTER PI}" + "):").grid(
                  row=0, column=0, pady=5)
        self.patch_size_spinbox = Spinbox(frame_feats, from_=3, to=30, width=3)
        self.patch_size_spinbox.delete(0, END)
        self.patch_size_spinbox.insert(END, 10)
        self.patch_size_spinbox.grid(row=0, column=1, padx=5)

        f1 = ttk.Labelframe(frame_feats, text='Mean filter')
        f1.grid(row=1, columnspan=2)

        Label(f1, text=u"\N{GREEK SMALL LETTER PI}").grid(row=0, column=0)
        Checkbutton(f1, text="R",
                    variable=self.features_vars[0]).grid(row=0, column=1)
        Checkbutton(f1, text="G",
                    variable=self.features_vars[1]).grid(row=0, column=2)
        Checkbutton(f1, text="B",
                    variable=self.features_vars[2]).grid(row=0, column=3)

        Label(f1, text=u"\N{GREEK SMALL LETTER PI}" + "/2").grid(row=1,
                                                                 column=0)
        Checkbutton(f1, text="R",
                    variable=self.features_vars[3]).grid(row=1, column=1)
        Checkbutton(f1, text="G",
                    variable=self.features_vars[4]).grid(row=1, column=2)
        Checkbutton(f1, text="B",
                    variable=self.features_vars[5]).grid(row=1, column=3)

        f2 = ttk.Labelframe(frame_feats, text="Gaussian filter")
        f2.grid(row=2, columnspan=2)

        Label(f2, text=str(1.0)).grid(row=0, column=0)
        Checkbutton(f2, text="R",
                    variable=self.features_vars[6]).grid(row=0, column=1)
        Checkbutton(f2, text="G",
                    variable=self.features_vars[7]).grid(row=0, column=2)
        Checkbutton(f2, text="B",
                    variable=self.features_vars[8]).grid(row=0, column=3)

        Label(f2, text=str(3.5)).grid(row=1, column=0)
        Checkbutton(f2, text="R",
                    variable=self.features_vars[9]).grid(row=1, column=1)
        Checkbutton(f2, text="G",
                    variable=self.features_vars[10]).grid(row=1, column=2)
        Checkbutton(f2, text="B",
                    variable=self.features_vars[11]).grid(row=1, column=3)

        f3 = ttk.Labelframe(frame_feats, text="Laplacian of gaussian")
        f3.grid(row=3, columnspan=2)

        Label(f3, text=str(2.0)).grid(row=0, column=0)
        Checkbutton(f3, text="R",
                    variable=self.features_vars[12]).grid(row=0, column=1)
        Checkbutton(f3, text="G",
                    variable=self.features_vars[13]).grid(row=0, column=2)
        Checkbutton(f3, text="B",
                    variable=self.features_vars[14]).grid(row=0, column=3)

        Label(f3, text=str(3.5)).grid(row=1, column=0)
        Checkbutton(f3, text="R",
                    variable=self.features_vars[15]).grid(row=1, column=1)
        Checkbutton(f3, text="G",
                    variable=self.features_vars[16]).grid(row=1, column=2)
        Checkbutton(f3, text="B",
                    variable=self.features_vars[17]).grid(row=1, column=3)

        f4 = ttk.Labelframe(frame_feats, text="Haar-like features")
        f4.grid(row=1, rowspan=2, column=3, padx=5)

        Checkbutton(f4, image=self.hf0_img,
                    variable=self.features_vars[18]).grid(row=0, column=0)
        Checkbutton(f4, image=self.hf1_img,
                    variable=self.features_vars[19]).grid(row=0, column=1)
        Checkbutton(f4, image=self.hf2_img,
                    variable=self.features_vars[20]).grid(row=1, column=0)
        Checkbutton(f4, image=self.hf3_img,
                    variable=self.features_vars[21]).grid(row=1, column=1)
        Checkbutton(f4, image=self.hf4_img,
                    variable=self.features_vars[22]).grid(row=2, column=0)
        Checkbutton(f4, image=self.hf5_img,
                    variable=self.features_vars[23]).grid(row=2, column=1)

        buttons_paned_window = PanedWindow(frame_feats, orient=VERTICAL)
        buttons_paned_window.grid(row=3, column=3)

        self.select_all_button = Button(buttons_paned_window,
                                        text="Select all",
                                        command=self._select_all)
        buttons_paned_window.add(self.select_all_button)

        self.clear_selection_button = Button(buttons_paned_window,
                                             text="Clear selection",
                                             command=self._clear_selection)
        buttons_paned_window.add(self.clear_selection_button)

        # default values
        for j in [0, 1, 3, 6, 7, 9, 15, 21, 23]:
            self.features_vars[j].set(1)

        # FOREST FRAMES
        # number of trees
        f5 = ttk.Labelframe(frame_forest, text="Number of trees")
        f5.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f5, text="N").grid(row=1, column=0)
        self.num_trees_scale = Scale(f5,
                                     from_=5,
                                     to=500,
                                     resolution=5,
                                     orient=HORIZONTAL)
        self.num_trees_scale.set(300)
        self.num_trees_scale.grid(row=0, column=1, rowspan=2)

        # depth single tree
        f6 = ttk.Labelframe(frame_forest, text="Depth single tree")
        f6.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f6, text="d").grid(row=1, column=0)
        self.depth_tree_scale = Scale(f6, from_=2, to=20, orient=HORIZONTAL)
        self.depth_tree_scale.set(3)
        self.depth_tree_scale.grid(row=0, column=1, rowspan=2)

        # percentage number of features
        f7 = ttk.Labelframe(frame_forest, text="% subset of features")
        f7.grid(row=2, columnspan=2, pady=5, padx=5)
        Label(f7, text="m").grid(row=1, column=0)
        self.percentage_feats_scale = Scale(f7,
                                            from_=0.0,
                                            to=1,
                                            resolution=0.05,
                                            orient=HORIZONTAL)
        self.percentage_feats_scale.set(0.5)
        self.percentage_feats_scale.grid(row=0, column=1, rowspan=2)

        # mser frame
        # delta
        f8 = ttk.Labelframe(frame_mser, text="Delta")
        f8.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f8, text=u"\N{GREEK SMALL LETTER DELTA}").grid(row=1, column=0)
        self.delta_scale = Scale(f8,
                                 from_=1,
                                 to=10,
                                 resolution=1,
                                 orient=HORIZONTAL)
        self.delta_scale.set(2)
        self.delta_scale.grid(row=0, column=1, rowspan=2)

        # min area
        f9 = ttk.Labelframe(frame_mser, text="Minimum area")
        f9.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f9, text="m").grid(row=1, column=0)
        self.min_area_scale = Scale(f9, from_=2, to=200, orient=HORIZONTAL)
        self.min_area_scale.set(10)
        self.min_area_scale.grid(row=0, column=1, rowspan=2)

        # percentage number of features
        f10 = ttk.Labelframe(frame_mser, text="Maximum area")
        f10.grid(row=2, columnspan=2, pady=5, padx=5)
        Label(f10, text="M").grid(row=1, column=0)
        self.max_area_scale = Scale(f10,
                                    from_=50,
                                    to=1000,
                                    resolution=5,
                                    orient=HORIZONTAL)
        self.max_area_scale.set(350)
        self.max_area_scale.grid(row=0, column=1, rowspan=2)

        # mser image
        f11 = ttk.Labelframe(frame_mser)
        f11.grid(row=0, rowspan=3, column=2, padx=5)

        self.mser_img_array = Image.fromarray(self.mser_area, "RGB")
        self.mser_img = ImageTk.PhotoImage(self.mser_img_array)

        img_label = Label(f11, image=self.mser_img)
        img_label.grid(row=0, column=0)

        buttons_p_w_mser = PanedWindow(f11, orient=HORIZONTAL)
        try_button = Button(f11, text="Try", command=self.try_mser)
        buttons_p_w_mser.add(try_button)
        change_button = Button(f11, text="New img", command=self.change_mser)
        buttons_p_w_mser.add(change_button)
        buttons_p_w_mser.grid(row=1, column=0)

        # other frame
        f12 = ttk.Labelframe(frame_other, text="Refinement")
        f12.grid(row=0, columnspan=2, pady=5, padx=5)
        Label(f12, text=u"\N{GREEK CAPITAL LETTER PHI}_l").grid(row=1,
                                                                column=0)
        self.low_thresh_scale = Scale(f12,
                                      from_=0,
                                      to=1,
                                      resolution=0.05,
                                      orient=HORIZONTAL,
                                      length=90)
        self.low_thresh_scale.set(0.45)
        self.low_thresh_scale.grid(row=0, column=1, rowspan=2)
        Label(f12, text=u"\N{GREEK CAPITAL LETTER PHI}_h").grid(row=3,
                                                                column=0)
        self.high_thresh_scale = Scale(f12,
                                       from_=0,
                                       to=1,
                                       resolution=0.05,
                                       orient=HORIZONTAL,
                                       length=90)
        self.high_thresh_scale.set(0.65)
        self.high_thresh_scale.grid(row=2, column=1, rowspan=2)

        f13 = ttk.Labelframe(frame_other, text="Dots distance")
        f13.grid(row=1, columnspan=2, pady=5, padx=5)
        Label(f13, text=u"     \N{GREEK SMALL LETTER SIGMA}").grid(row=1,
                                                                   column=0)
        self.dots_distance_scale = Scale(f13,
                                         from_=1,
                                         to=20,
                                         resolution=1,
                                         orient=HORIZONTAL,
                                         length=90)
        self.dots_distance_scale.set(6)
        self.dots_distance_scale.grid(row=0, column=1, rowspan=2)

        f14 = ttk.Labelframe(frame_other, text="Tracks")
        f14.grid(row=0, column=3, pady=5, padx=5)
        Label(f14, text="N").grid(row=1, column=0)
        self.num_frames_tracks_spinbox = Spinbox(f14,
                                                 from_=2,
                                                 to=num_frames,
                                                 width=10)
        self.num_frames_tracks_spinbox.delete(0, END)
        self.num_frames_tracks_spinbox.insert(END, num_frames)
        self.num_frames_tracks_spinbox.grid(row=0, column=1, rowspan=2)

        Label(f14, text=u"\N{GREEK SMALL LETTER TAU}").grid(row=3, column=0)
        self.gaps_scale = Scale(f14,
                                from_=1,
                                to=10,
                                resolution=1,
                                orient=HORIZONTAL,
                                length=90)
        self.gaps_scale.set(2)
        self.gaps_scale.grid(row=2, column=1, rowspan=2)

        self.notebook.pack(padx=1, pady=1)

        save_button = Button(self,
                             text=" Save and Close window ",
                             command=self.withdraw)
        save_button.pack(pady=2)
Example #16
0
    def __init__(self):
        Game.__init__(self)
        import socket
        self.local = self.host = socket.gethostbyname(
            socket.gethostname())  # Get local machine ip
        from Tkinter import Tk, PanedWindow, StringVar, Entry, Button, VERTICAL, HORIZONTAL, Label
        fenetre = Tk()
        fenetre.title('Socket parameters')
        self.netgame_win = PanedWindow(fenetre, orient=VERTICAL)
        host_zone = PanedWindow(self.netgame_win, orient=HORIZONTAL)
        host = StringVar()
        host.set(self.local)

        def modifHost(*args):
            self.host = host.get()
            if self.local == self.host:
                start_button.config(text="Create")
            else:
                start_button.config(text="Join")

        host.trace("w", modifHost)
        host_wid = Entry(host_zone, width=30, textvariable=host)
        host_wid.pack()
        host_label = Label(fenetre, text="Host (you are " + self.local + ") :")
        host_zone.add(host_label)
        host_zone.add(host_wid)
        self.netgame_win.add(host_zone)
        port_zone = PanedWindow(self.netgame_win, orient=HORIZONTAL)
        port = StringVar()
        self.port = 52333
        port.set(str(self.port))

        # adress_wid=Label(None, textvariable=self.cost, background='red',width=5, anchor=W)
        def modifPort(*args):
            self.port = port.get()

        port.trace("w", modifPort)
        port_wid = Entry(port_zone, width=30, textvariable=port)
        port_wid.pack()
        port_label = Label(fenetre, text="Port :")
        port_zone.add(port_label)
        port_zone.add(port_wid)
        self.netgame_win.add(port_zone)

        #Create the open button
        def start():
            fenetre.destroy()

        start_button = Button(self.netgame_win, text="Create", command=start)
        self.netgame_win.add(start_button)
        self.netgame_win.pack()
        fenetre.focus_set()
        start_button.focus()
        fenetre.mainloop()
        # Import socket module
        self.soc = socket.socket()  # Reserve a port for your service.
        if self.local == self.host:
            self.soc.bind((self.host, self.port))  # Bind to the port
            print "socket listening"
            self.soc.listen(5)  # Now wait for client connection.

            self.soc, addr = self.soc.accept(
            )  # Establish connection with client.
            print 'Got connection from', addr
            #self.soc.send('Thank you for connecting')
            #c.close()                # Close the connection
            self.firstplayer = choice([1, 2])
            print "FIRST PLAYER IS", 1
            self.soc.send(str(3 - self.firstplayer))
        else:
            self.soc.connect((self.host, self.port))
            print "connect ok"
            p = self.soc.recv(1024)
            try:
                self.firstplayer = int(p)
            except:
                print "error concerning first player, got ", p