Exemplo n.º 1
0
    def _options(self, cnf, kw=None):
        if kw:
            cnf = Tkinter._cnfmerge((cnf, kw))
        else:
            cnf = Tkinter._cnfmerge(cnf)

        res = ()
        for k, v in cnf.iteritems():
            if callable(v):
                if k in self._tabsubst_commands:
                    v = "%s %s"  % (self._register(v, self._tabsubst),
                                    ' '.join(self._tabsubst_format))
                else:
                    v = self._register(v)
            res += ('-%s' % k, v)

        return res
Exemplo n.º 2
0
    def __create_widgets(self):
        frame = Tix.Frame(
            self,
            class_="Toolbar",
            borderwidth=2,
            padx=2,
            pady=2,
            relief="groove",
            )
        self.cmdbar = frame
        frame.grid(sticky="we")        
        self.itemlist_menu = Tix.OptionMenu(
            frame,
            label=_("Select Item:"),
            variable=self.var_itemname,
            command=self.select_item,
            options="label.relief flat label.anchor w "
                    "menubutton.width 32 menubutton.relief groove"
            )
        self.itemlist_menu.grid(sticky="we")
        b = Tix.Button(
            frame,
            text=_("Remove"),
            command=self.__action_remove,
            width=8,
            )
        b.grid(row=0, column=1, padx=20)
        
        w = Tix.Label(frame, text=_("New item:"))
        w.grid(row=0, column=2, padx=2, sticky='e')
        w = Tix.Entry(frame, width=30)
        w.grid(row=0, column=3, padx=2, sticky='e')
        self.item_entry = w
        b = Tix.Button(
            frame,
            text=_("Add"),
            command=self.__action_add,
            width=8,
            )
        b.grid(row=0, column=4, padx=4, sticky='e')
        
        b = Tix.Button(
            frame,
            text=_("Clone"),
            command=self.__action_clone,
            width=8,
            )
        b.grid(row=0, column=5, padx=4)


        frame = Tix.Frame(self)
        frame.grid(sticky="nesw")
        frame.columnconfigure(1, weight=1)
        w = Tix.Frame(
            frame,
            borderwidth=2,
            padx=2,
            pady=2,
            relief="groove",
            )
        w.grid(row=0, column=0, sticky="nesw")
        w.columnconfigure(0, weight=1)
        self.__create_property_window(w)

        self.item_canvas = VisualItem(self)
        self.item_canvas.grid(in_=frame, row=0, column=1, sticky="nesw")
        
        frame = Tix.Frame(
            self, 
            class_="Toolbar", 
            pady=10, 
            )
        frame.grid(row=2, column=0)
        # 命令栏
        b = Tix.Button(
            frame,
            text=_("Random Data"),
            command=self.__action_random_data,
            width=12,
            )
        b.grid(row=0, column=0, padx=20)
        
        b = Tix.Button(
            frame,
            text=_("Apply"),
            command=self.__action_apply,
            width=8,
            )
        b.grid(row=0, column=10, padx=20)
        
        b = Tix.Button(
            frame,
            text=_("Close"),
            command=lambda : self.winfo_toplevel().withdraw(),
            width=8,
            )
        b.grid(row=0, column=11, padx=20)
Exemplo n.º 3
0
            if "n" in anchor:
                yamount = 0
            elif "s" in anchor:
                yamount = y2 - ipady - y
            else:
                yamount = (y2 - ipady - y) / 2

        return (xamount, yamount)

class DataPool(Tix.Toplevel):

    def __init__(self, master, filename=None):
        Tix.Toplevel.__init__(self, master)
        self.withdraw()
        self.title(_("Data Pool"))
        self.geometry('-200-100')
        self.resizable(False, False)
        self.protocol("WM_DELETE_WINDOW", self.withdraw)
        w = DataPoolFrame(self, filename)
        w.grid(sticky="nesw")

if __name__ == "__main__":
    import gettext
    gettext.NullTranslations().install()

    root = Tix.Tk()
    # w = DataPool(root, filename='datapool.data')
    w = DataPool(root)
    w.deiconify()
    w.state('normal')
    w.mainloop()
Exemplo n.º 4
0
 def create_contents(self):
     opts = self._opts.copy()
     for opt in ('delay', 'follow_mouse', 'state'):
         del opts[opt]
     label = Tix.Label(self._tipwindow, **opts)
     label.pack()
Exemplo n.º 5
0
    def __init__(self, name, num_vals, light_list, vals, handler):
        self.handler = handler
        self.light_list = light_list
        Tix.Toplevel.__init__(self)
        self.title(name)

        svalues = Tix.ScrolledWindow(self)
        self.values = svalues.window
        self.lights = []

        row = 0
        for i in range(0, num_vals):
            if (len(vals) <= i):
                ivals = ("", "black", '0', '1')
            else:
                ivals = vals[i]
                pass

            label = Tix.Label(self.values, text="Light " + str(i))
            label.grid(row=row, column=0, sticky="e")
            if (light_list[i][0]):
                lc = Tix.BooleanVar()
                lcw = Tix.Checkbutton(self.values,
                                      text="Local Control",
                                      variable=lc)
                lc.set(ivals[0] == "lc")
                lcw.grid(row=row, column=1, sticky="ew")
                row += 1
            else:
                lc = None
                pass

            color = EnumHolder()
            colorw = Tix.Select(self.values,
                                label="Color",
                                allowzero=0,
                                radio=1,
                                command=color.SelectType)
            for v in light_list[i][1]:
                colorw.add(v, text=v)
                pass
            colorw.configure(value=ivals[1])
            colorw.grid(row=row, column=1, sticky="ew")
            row += 1

            ontime = Tix.LabelEntry(self.values, label="On Time")
            ontime.entry.insert("0", ivals[2])
            ontime.grid(row=row, column=1, sticky="ew")
            row += 1
            ontime = ontime.entry

            offtime = Tix.LabelEntry(self.values, label="Off Time")
            offtime.entry.insert("0", ivals[3])
            offtime.grid(row=row, column=1, sticky="ew")
            row += 1
            offtime = offtime.entry

            self.lights.append((lc, color, ontime, offtime))
            pass

        svalues.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)

        bbox = Tix.ButtonBox(self)
        bbox.add("cancel", text="Cancel", command=lambda w=self: w.cancel())
        bbox.add("ok", text="Ok", command=lambda w=self: w.ok_press())
        bbox.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

        self.bind("<Destroy>", self.OnDestroy)
        return
Exemplo n.º 6
0
    def project_save(self):
        if self.cpu_once == 0:
            self.message("Cpu and Mainboard is not chosen yet")
            self.welcome()
            return
        if self.device_once == 0:
            self.message("Peripherial is not chosen yet")
            self.welcome()
            return
        if self.memory_once == 0:
            self.message("Memory is not chose yet")
            self.welcome()
            return

        try:
            tmp_fd = open("skyeye.conf.koo", "w")

        except:
            self.message("./skyeye.conf.koo write failure")
            return

        top = self.skyeye_body("Write configuration file")

        tmp = Tix.Frame(top, padx=10, pady=25)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Below are the saved information:')
        b.grid(row=0, padx=5, pady=3, sticky=W + E)

        str = "cpu\t:" + self.cpu + "\n"
        str += "mach\t:" + self.board + "\n"

        for x in self.membank:
            tmpp = "membank\t:map=" + x["map"] + ",type=" + x[
                "type"] + ",addr=" + x["addr"] + ",size=" + x["size"]
            if x["file"] != "":
                tmpp += ",file=" + x["file"]
            str += tmpp + "\n"

        if self.lcd != "":
            str += "lcd\t:state=on,type=" + self.lcd + ",mode=gtk\n"

        if self.net != "":
            pass  # i have to find one demo ...

        str += "dbct\t:state=on\n"

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='%s' % str)
        b.grid(row=1, padx=5, pady=3, sticky=W + E)

        tmp_fd.write(str)

        tmp.grid(padx=5, pady=25)

        self.message("Information has been written to ./skyeye.conf.koo")

        self.skyeye_redobody()
Exemplo n.º 7
0
    def skyeye_mainmenu(self):
        top = self.root
        w = Tix.Frame(top, bd=2, relief=RAISED)
        file = Tix.Menubutton(w, text='File', underline=0, takefocus=0)
        view = Tix.Menubutton(w, text='Setting', underline=0, takefocus=0)
        project = Tix.Menubutton(w, text='Project', underline=0, takefocus=0)
        execute = Tix.Menubutton(w, text='Execute', underline=0, takefocus=0)
        tools = Tix.Menubutton(w, text='Tools', underline=0, takefocus=0)
        window = Tix.Menubutton(w, text='Window', underline=0, takefocus=0)
        help = Tix.Menubutton(w, text='Help', underline=0, takefocus=0)

        file.pack(side=LEFT)
        project.pack(side=LEFT)
        view.pack(side=LEFT)
        execute.pack(side=LEFT)
        tools.pack(side=LEFT)
        window.pack(side=LEFT)
        help.pack(side=RIGHT)

        file_m = Tix.Menu(file, tearoff=0)
        file['menu'] = file_m
        view_m = Tix.Menu(view, tearoff=0)
        view['menu'] = view_m
        project_m = Tix.Menu(project, tearoff=0)
        project['menu'] = project_m
        execute_m = Tix.Menu(execute, tearoff=0)
        execute['menu'] = execute_m
        tools_m = Tix.Menu(tools, tearoff=0)
        tools['menu'] = tools_m
        window_m = Tix.Menu(window, tearoff=0)
        window['menu'] = window_m
        help_m = Tix.Menu(help, tearoff=0)
        help['menu'] = help_m

        file_m.add_command(label='Open file',
                           underline=1,
                           command=self.file_openfile)
        file_m.add_command(label='Close file',
                           underline=1,
                           command=self.file_closefile)
        file_m.add_command(label='Exit', underline=1, command=self.file_exit)

        view_m.add_radiobutton(label='Cpu', underline=1, command=self.view_cpu)
        view_m.add_radiobutton(label='Device',
                               underline=1,
                               command=self.view_device)
        view_m.add_radiobutton(label='Memory',
                               underline=1,
                               command=self.view_memory)
        view_m.add_radiobutton(label='System Info',
                               underline=1,
                               command=self.view_info)

        project_m.add_command(label='New',
                              underline=1,
                              command=self.project_new)
        project_m.add_command(label='Save',
                              underline=1,
                              command=self.project_save)

        execute_m.add_command(label='Compile',
                              underline=1,
                              command=self.execute_compile)
        execute_m.add_command(label='Compile current file',
                              underline=1,
                              command=self.execute_compilecurrentfile)
        execute_m.add_command(label='Run',
                              underline=1,
                              command=self.execute_run)
        execute_m.add_command(label='Compile & Run',
                              underline=1,
                              command=self.execute_compileandrun)
        execute_m.add_command(label='Rebuild All',
                              underline=1,
                              command=self.execute_rebuildall)
        execute_m.add_command(label='Clean',
                              underline=1,
                              command=self.execute_clean)

        tools_m.add_command(label='Compiler Option',
                            underline=1,
                            command=self.tools_compileroption)
        tools_m.add_command(label='Linker Option',
                            underline=1,
                            command=self.tools_linkeroption)
        tools_m.add_command(label='Makefile Option',
                            underline=1,
                            command=self.tools_makefileoption)

        window_m.add_command(label='Max', underline=0, command=self.window_max)
        window_m.add_command(label='Restore',
                             underline=0,
                             command=self.window_restore)

        help_m.add_command(label='about', underline=0, command=self.help_about)
        return w
Exemplo n.º 8
0
    def __init__(self, widget, captureManager):
        self.captureManager = captureManager
        self.sourcesList = []
        self.prevSelectedSourceIndex = -1
        self.prevSelectedMediaTypeIndex = -1
        self.sourceComboBox = Tix.ComboBox(widget,
                                           label="Source: ",
                                           command=self.selectSource)
        self.sourceComboBox.pack(side=Tix.TOP, fill=Tix.X)
        self.sourceControl = self.captureManager.createSourceControl()
        self.sinkControl = self.captureManager.createSinkControl()
        self.sessionControl = self.captureManager.createSessionControl()
        self.session = -1
        xmlstring = self.sourceControl.getCollectionOfSources()
        selfSources = ElementTree.fromstring(xmlstring)
        self.sources = ElementPath.findall(selfSources, "Source")
        for source in self.sources:
            friendlyname = ''
            state = False
            for attributes in ElementPath.findall(source, "Source.Attributes"):
                for attribute in ElementPath.findall(attributes, "Attribute"):
                    if (attribute.get('Name') ==
                            'MF_DEVSOURCE_ATTRIBUTE_FRIENDLY_NAME'):
                        friendlyname = attribute.find('SingleValue').get(
                            'Value')
                    if (attribute.get('Name') ==
                            'MF_DEVSOURCE_ATTRIBUTE_MEDIA_TYPE'):
                        parts = attribute.find('Value.ValueParts').findall(
                            "ValuePart")
                        for part in parts:
                            if (part.get('Value') == 'MFMediaType_Video'):
                                state = True

            if (state):
                self.sourceComboBox.insert(Tix.END, friendlyname)
                self.sourcesList.append(source)
        self.mediaTypeComboBox = Tix.ComboBox(widget,
                                              label="MediaTypes: ",
                                              state='disabled',
                                              command=self.selectMediaType)
        self.mediaTypeComboBox.pack(side=Tix.TOP, fill=Tix.X)
        self.controlBtnbox = Tix.ButtonBox(widget, orientation=Tix.HORIZONTAL)
        self.startBtn = self.controlBtnbox.add(
            'start',
            text='Start',
            underline=0,
            width=6,
            state='disabled',
            command=lambda widget=widget: self.startCaptureSession())
        self.optionsBtn = self.controlBtnbox.add(
            'options',
            text='Options',
            underline=0,
            width=6,
            state='disabled',
            command=lambda widget=widget: self.options())
        self.stopBtn = self.controlBtnbox.add(
            'stop',
            text='Stop',
            underline=0,
            width=6,
            state='disabled',
            command=lambda widget=widget: self.stopCaptureSession())
        self.controlBtnbox.pack(side=Tix.TOP, fill=Tix.X)

        self.frame = Tkinter.Frame(widget, relief=RIDGE, borderwidth=2)
        self.frame.pack(fill=BOTH, expand=1)
Exemplo n.º 9
0
    def open_conf_dialog(self,
                         num_cell=0,
                         direction='vertical',
                         type='num',
                         cellwidth='0',
                         cellheight='0',
                         space='0'):
        """
        Abre o diálogo de configuração do campo selecionado
        @param num_cell int : quantidade de células do campo
        @param direction string: direção do campo (vertical ou horizontal)
        @param type string: tipo do campo (num ou char)
        @param cellwidth string: largura da célula do campo em pixels
        @param cellheight string: altura da célula do campo em pixels
        @param space string: espaçamento entre células em pixels
        """
        self.top = Toplevel(self.root)
        self.top.title('COnfigure field')
        self.top.protocol("WM_DELETE_WINDOW", self.cancel_field)

        self.imidbox = Checkbutton(self.top,
                                   text="Identifier",
                                   variable=self.imidvar)
        self.imidbox.pack()

        Label(self.top, text='Number of cells:').pack()
        self.listnumber = Entry(self.top)
        self.listnumber.insert(0, num_cell)
        self.listnumber.pack()

        Label(self.top, text='Direction:').pack()
        self.listdirection = Tix.ComboBox(self.top, selectmode=SINGLE)
        self.listdirection.pack()
        self.listdirection.insert(END, 'horizontal')
        self.listdirection.insert(END, 'vertical')
        self.listdirection['value'] = direction

        Label(self.top, text='Type:').pack()
        self.listtype = Tix.ComboBox(self.top, selectmode=SINGLE)
        self.listtype.pack()
        self.listtype.insert(END, 'num')
        self.listtype.insert(END, 'char')
        self.listtype['value'] = type

        Label(self.top, text='Cell width (px):').pack()
        self.cellwidth = Entry(self.top)
        self.cellwidth.pack()
        self.cellwidth.insert(0, cellwidth)

        Label(self.top, text='Cell height (px):').pack()
        self.cellheight = Entry(self.top)
        self.cellheight.pack()
        self.cellheight.insert(0, cellheight)

        Label(self.top, text='Spacing (px):').pack()
        self.space = Entry(self.top)
        self.space.pack()
        self.space.insert(0, space)

        Button(self.top, text="OK", command=self.save_field).pack()
        if num_cell == 0:
            Button(self.top, text="Cancel", command=self.cancel_field).pack()
        else:
            Button(self.top, text="Cancel", command=self.top.destroy).pack()
Exemplo n.º 10
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # We create the frame and the ScrolledHList widget
        # at the top of the dialog box
        #
        top = Tix.Frame(w, relief=Tix.RAISED, bd=1)

        # Put a simple hierachy into the HList (two levels). Use colors and
        # separator widgets (frames) to make the list look fancy
        #
        top.a = Tix.ScrolledHList(top)
        top.a.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)

        # This is our little relational database
        #
        bosses = [('jeff', 'Jeff Waxman'), ('john', 'John Lee'),
                  ('peter', 'Peter Kenson')]

        employees = [('alex', 'john', 'Alex Kellman'),
                     ('alan', 'john', 'Alan Adams'),
                     ('andy', 'peter', 'Andreas Crawford'),
                     ('doug', 'jeff', 'Douglas Bloom'),
                     ('jon', 'peter', 'Jon Baraki'),
                     ('chris', 'jeff', 'Chris Geoffrey'),
                     ('chuck', 'jeff', 'Chuck McLean')]

        hlist = top.a.hlist

        # Let configure the appearance of the HList subwidget
        #
        hlist.config(separator='.', width=25, drawbranch=0, indent=10)

        count = 0
        for boss, name in bosses:
            if count:
                f = Tix.Frame(hlist,
                              name='sep%d' % count,
                              height=2,
                              width=150,
                              bd=2,
                              relief=Tix.SUNKEN)

                hlist.add_child(itemtype=Tix.WINDOW,
                                window=f,
                                state=Tix.DISABLED)

            hlist.add(boss, itemtype=Tix.TEXT, text=name)
            count = count + 1

        for person, boss, name in employees:
            # '.' is the separator character we chose above
            #
            key = boss + '.' + person
            #    ^^^^                ^^^^^^
            #    parent entryPath /  child's name

            hlist.add(key, text=name)

            # [Hint] Make sure the keys (e.g. 'boss.person') you choose
            #    are unique names. If you cannot be sure of this (because of
            #    the structure of your database, e.g.) you can use the
            #    "add_child" command instead:
            #
            #  hlist.addchild( boss,  text=name)
            #                  ^^^^
            #                  parent entryPath

        # Use a ButtonBox to hold the buttons.
        #
        box = Tix.ButtonBox(top, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.okcmd)

        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)

        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Exemplo n.º 11
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        group = Tix.LabelEntry(w, label='Newsgroup:', options='entry.width 25')
        group.entry.insert(0, 'comp.lang.python')
        pane = Tix.PanedWindow(w, orientation='vertical')

        p1 = pane.add('list', min=70, size=100)
        p2 = pane.add('text', min=70)
        list = Tix.ScrolledListBox(p1)
        list.listbox['width'] = 80
        list.listbox['height'] = 5
        text = Tix.ScrolledText(p2)
        text.text['width'] = 80
        text.text['height'] = 20

        list.listbox.insert(Tix.END,
                            "  12324 Re: Tkinter is good for your health")
        list.listbox.insert(Tix.END,
                            "+ 12325 Re: Tkinter is good for your health")
        list.listbox.insert(
            Tix.END,
            "+ 12326 Re: Tix is even better for your health (Was: Tkinter is good...)"
        )
        list.listbox.insert(
            Tix.END,
            "  12327 Re: Tix is even better for your health (Was: Tkinter is good...)"
        )
        list.listbox.insert(
            Tix.END,
            "+ 12328 Re: Tix is even better for your health (Was: Tkinter is good...)"
        )
        list.listbox.insert(
            Tix.END,
            "  12329 Re: Tix is even better for your health (Was: Tkinter is good...)"
        )
        list.listbox.insert(
            Tix.END,
            "+ 12330 Re: Tix is even better for your health (Was: Tkinter is good...)"
        )

        text.text['bg'] = list.listbox['bg']
        text.text['wrap'] = 'none'
        text.text.insert(
            Tix.END, """
    Mon, 19 Jun 1995 11:39:52        comp.lang.python              Thread   34 of  220
    Lines 353       A new way to put text and bitmaps together iNo responses
    [email protected]                Ioi K. Lam at University of Pennsylvania

    Hi,

    I have implemented a new image type called "compound". It allows you
    to glue together a bunch of bitmaps, images and text strings together
    to form a bigger image. Then you can use this image with widgets that
    support the -image option. For example, you can display a text string string
    together with a bitmap, at the same time, inside a TK button widget.
    """)
        text.text['state'] = 'disabled'

        list.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)
        text.pack(expand=1, fill=Tix.BOTH, padx=4, pady=6)

        group.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH)
        pane.pack(side=Tix.TOP, padx=3, pady=3, fill=Tix.BOTH, expand=1)

        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.quitcmd)
        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)
        box.pack(side=Tix.BOTTOM, fill=Tix.X)
Exemplo n.º 12
0
        if isinstance(data_element.value, compat.text_type):
            tree.hlist.add(node_id, text=compat.text_type(data_element))
        else:
            tree.hlist.add(node_id, text=str(data_element))
        if hide:
            tree.hlist.hide_entry(node_id)
        if data_element.VR == "SQ":  # a sequence
            for i, dataset in enumerate(data_element.value):
                item_id = node_id + "." + str(i + 1)
                sq_item_description = data_element.name.replace(
                    " Sequence", "")  # XXX not i18n
                item_text = "{0:s} {1:d}".format(sq_item_description, i + 1)
                tree.hlist.add(item_id, text=item_text)
                tree.hlist.hide_entry(item_id)
                recurse_tree(tree, dataset, item_id, hide=True)


if __name__ == '__main__':
    import sys
    import pydicom

    if len(sys.argv) != 2:
        print("Please supply a dicom file name:\n")
        print(usage)
        sys.exit(-1)
    root = tkinter_tix.Tk()
    root.geometry("{0:d}x{1:d}+{2:d}+{3:d}".format(1200, 900, 0, 0))
    root.title("DICOM tree viewer - " + sys.argv[1])

    RunTree(root, sys.argv[1])
    root.mainloop()
Exemplo n.º 13
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        z = w.winfo_toplevel()
        z.wm_protocol("WM_DELETE_WINDOW", lambda self=self: self.quitcmd())

        # We create the frame and the ScrolledHList widget
        # at the top of the dialog box
        #
        top = Tix.Frame(w, relief=Tix.RAISED, bd=1)

        # Put a simple hierachy into the HList (two levels). Use colors and
        # separator widgets (frames) to make the list look fancy
        #
        top.a = Tix.ScrolledHList(top,
                                  options='hlist.columns 3 hlist.header 1')
        top.a.pack(expand=1, fill=Tix.BOTH, padx=10, pady=10, side=Tix.TOP)

        hlist = top.a.hlist

        # Create the title for the HList widget
        #	>> Notice that we have set the hlist.header subwidget option to true
        #      so that the header is displayed
        #

        boldfont = hlist.tk.call('tix', 'option', 'get', 'bold_font')

        # First some styles for the headers
        style = {}
        style['header'] = Tix.DisplayStyle(Tix.TEXT,
                                           refwindow=hlist,
                                           anchor=Tix.CENTER,
                                           padx=8,
                                           pady=2,
                                           font=boldfont)

        hlist.header_create(0,
                            itemtype=Tix.TEXT,
                            text='Name',
                            style=style['header'])
        hlist.header_create(1,
                            itemtype=Tix.TEXT,
                            text='Position',
                            style=style['header'])

        # Notice that we use 3 columns in the hlist widget. This way when the user
        # expands the windows wide, the right side of the header doesn't look
        # chopped off. The following line ensures that the 3 column header is
        # not shown unless the hlist window is wider than its contents.
        #
        hlist.column_width(2, 0)

        # This is our little relational database
        #
        boss = ('doe', 'John Doe', 'Director')

        managers = [('jeff', 'Jeff Waxman', 'Manager'),
                    ('john', 'John Lee', 'Manager'),
                    ('peter', 'Peter Kenson', 'Manager')]

        employees = [('alex', 'john', 'Alex Kellman', 'Clerk'),
                     ('alan', 'john', 'Alan Adams', 'Clerk'),
                     ('andy', 'peter', 'Andreas Crawford', 'Salesman'),
                     ('doug', 'jeff', 'Douglas Bloom', 'Clerk'),
                     ('jon', 'peter', 'Jon Baraki', 'Salesman'),
                     ('chris', 'jeff', 'Chris Geoffrey', 'Clerk'),
                     ('chuck', 'jeff', 'Chuck McLean', 'Cleaner')]

        style['mgr_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['mgr_posn'] = Tix.DisplayStyle(Tix.TEXT, padx=8, refwindow=hlist)

        style['empl_name'] = Tix.DisplayStyle(Tix.TEXT, refwindow=hlist)

        style['empl_posn'] = Tix.DisplayStyle(Tix.TEXT,
                                              padx=8,
                                              refwindow=hlist)

        # Let configure the appearance of the HList subwidget
        #
        hlist.config(separator='.', width=25, drawbranch=0, indent=10)
        hlist.column_width(0, chars=20)

        # Create the boss
        #
        hlist.add('.',
                  itemtype=Tix.TEXT,
                  text=boss[1],
                  style=style['mgr_name'])
        hlist.item_create('.',
                          1,
                          itemtype=Tix.TEXT,
                          text=boss[2],
                          style=style['mgr_posn'])

        # Create the managers
        #

        for key, name, posn in managers:
            e = '.' + key
            hlist.add(e, itemtype=Tix.TEXT, text=name, style=style['mgr_name'])
            hlist.item_create(e,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['mgr_posn'])

        for key, mgr, name, posn in employees:
            # "." is the separator character we chose above

            entrypath = '.' + mgr + '.' + key

            #           ^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^
            #	    parent entryPath / child's name

            hlist.add(entrypath, text=name, style=style['empl_name'])
            hlist.item_create(entrypath,
                              1,
                              itemtype=Tix.TEXT,
                              text=posn,
                              style=style['empl_posn'])

        # Use a ButtonBox to hold the buttons.
        #
        box = Tix.ButtonBox(top, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.okcmd)

        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)

        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Exemplo n.º 14
0
#!/usr/local/bin/python
Exemplo n.º 15
0
    def set_context(self, context):
        # only set the context if it is fairly interpretable
        if context is None or (context.as_date() or context.as_time()):
            self.tktime.time_context = context
            self.tktime.sched_update(force_update=True)
        if context:
            self.contextlabel['text'] = str(context)
        else:
            self.contextlabel['text'] = ""
    def context_has_parses(self, segmentnum, segment, parses):
        """This is called when the parser has new parses for a segment.
        We set the context to be the first parse from the first segment
        (this, of course, can be manually overridden)."""
        if segmentnum == 0:
            if parses:
                parse, score = parses[0]
                self.set_context(parse)
            else:
                self.set_context(None)
    def typed_in_context(self, *args):
        # if there's no text in the context, set the context to None
        if not self.context.has_text():
            self.set_context(None)

if __name__ == "__main__":
    root = Tk.Tk()
    root.title("TkTime")
    tktimewithcontext = TkTimeWithContext(root)
    tktimewithcontext.pack(fill='both', expand=1)
    Tk.mainloop()
Exemplo n.º 16
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013-2018, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------


import Tix as tix

root = tix.Tk()
root.title("Test for TiX")

tix.Label(text="Press <ESC> to exit").pack()
tix.DirList(root).pack()
tix.Button(root, text="Close", command=root.destroy).pack()
root.bind("<Escape>", lambda x: root.destroy())

tix.mainloop()
Exemplo n.º 17
0
    def __init__(self, contype, parent):
        Tix.Frame.__init__(self, parent)
        self.contype = contype
        self.fields = []

        args = OpenIPMI.alloc_empty_args(str(contype))
        self.args = args

        self.errstr = gui_errstr.ErrStr(self)
        self.errstr.pack(side=Tix.TOP, fill=Tix.X, expand=1)

        i = 0
        rv = 0
        frame = None
        while (rv == 0):
            name = [""]
            vtype = [""]
            vrange = [""]
            vhelp = [""]
            value = [""]
            rv = args.get_val(i, name, vtype, vhelp, value, vrange)
            if (rv == 0):
                if (vhelp[0][0] == '*'):
                    optional = False
                    vhelp[0] = vhelp[0][1:]
                else:
                    optional = True
                    pass
                if (vhelp[0][0] == '!'):
                    password = True
                    vhelp[0] = vhelp[0][1:]
                else:
                    password = False
                    pass

                if (vtype[0] == "bool"):
                    if (frame == None):
                        didframe = True
                        frame = Tix.Frame(self)
                        frame.pack(side=Tix.TOP)
                        newframe = frame
                        pass
                    else:
                        newframe = None
                        pass
                    fw = Tix.BooleanVar()
                    w = Tix.Checkbutton(frame, text=name[0], variable=fw)
                    w.pack(side=Tix.LEFT, padx=10)
                    if ((value[0] != None) and (value[0] == "true")):
                        fw.set(True)
                        pass
                    pass
                elif (vtype[0] == "enum"):
                    do_box = False
                    fw = EnumHolder()
                    if (value[0] != None):
                        fw.set(value[0])
                        pass
                    else:
                        fw.set(vrange[0])
                        pass
                    w = Tix.Select(self,
                                   label=name[0],
                                   allowzero=0,
                                   radio=1,
                                   command=fw.SelectType)
                    for v in vrange:
                        w.add(v, text=v)
                        pass
                    newframe = None
                    w.invoke(fw.get())
                    w.pack()
                    pass
                elif (vtype[0] == "str") or (vtype[0] == "int"):
                    if (frame == None):
                        didframe = True
                        frame = Tix.Frame(self)
                        frame.pack(side=Tix.TOP)
                        newframe = frame
                        pass
                    else:
                        newframe = None
                        pass

                    if (value[0] == None):
                        value[0] = ""
                        pass
                    if (password):
                        options = "entry.show '*' entry.width 20"
                    else:
                        options = "entry.width 20"
                        pass
                    w = Tix.LabelEntry(frame, label=name[0], options=options)
                    w.entry.insert(Tix.END, value[0])
                    w.pack(side=Tix.LEFT, padx=10)
                    fw = w.entry
                    pass
                else:
                    i += 1
                    continue
                frame = newframe
                self.fields.append((i, name[0], vtype[0], fw))
                pass
            i += 1
            pass

        return
Exemplo n.º 18
0
    def view_device(self):
        self.message("You are now setting the peripherial information")
        if self.device_once == 1:
            self.net_lcd_flash_ok()
            return

        net_list = ["cs8900a", "rtl8091", "s3c4510b"]

        lcd_list = ["ep7312", "pxa", "s3c2410"]
        flash_list = ["ibm"]

        top = self.skyeye_body("Peripherial")
        net = Tix.LabelFrame(top, labelside="acrosstop", padx=5, pady=10)
        lcd = Tix.LabelFrame(top, labelside="acrosstop", padx=5, pady=10)
        flash = Tix.LabelFrame(top, labelside="acrosstop", padx=5, pady=10)

        self.net_v = Tix.StringVar()
        self.lcd_v = Tix.StringVar()
        self.flash_v = Tix.StringVar()

        net_s = Tix.Select(net,
                           label='Net Adapter',
                           allowzero=1,
                           radio=1,
                           orientation=Tix.VERTICAL,
                           labelside=Tix.TOP,
                           command=self.net_select,
                           variable=self.net_v)

        lcd_s = Tix.Select(lcd,
                           label='Lcd',
                           allowzero=1,
                           radio=1,
                           orientation=Tix.VERTICAL,
                           labelside=Tix.TOP,
                           command=self.lcd_select,
                           variable=self.lcd_v)

        flash_s = Tix.Select(flash,
                             label='Flash',
                             allowzero=1,
                             radio=1,
                             orientation=Tix.VERTICAL,
                             labelside=Tix.TOP,
                             command=self.flash_select,
                             variable=self.flash_v)

        ok = Tix.Button(top, text="OK", command=self.net_lcd_flash_ok)

        for x in net_list:
            net_s.add(x, text=x)
        for x in lcd_list:
            lcd_s.add(x, text=x)
        for x in flash_list:
            flash_s.add(x, text=x)

        net_s.pack(padx=5, pady=10)
        net.grid(row=0, column=0, padx=5, pady=10)
        lcd_s.pack(padx=5, pady=10)
        lcd.grid(row=0, column=1, padx=5, pady=10)
        flash_s.pack(padx=5, pady=10)
        flash.grid(row=0, column=2, padx=5, pady=10)
        ok.grid(row=1, column=1, columnspan=1, padx=5, pady=10)

        self.skyeye_redobody()
Exemplo n.º 19
0
            try:
                self.logwrite("Shutting down DySKT...", gui.LOG_NOTE)
                cmdline.service('dysktd', self._pwd, False)
            except RuntimeError as e:
                self.logwrite("Error shutting down DySKT: %s" % e, gui.LOG_ERR)
            else:
                self._setstate(_STATE_DYSKT_, False)
                self.logwrite("DySKT shut down")

    def _getpwd(self):
        """ prompts for sudo password until correct or canceled"""
        dlg = gui.PasswordDialog(self)
        try:
            # test out sudo pwd
            while not cmdline.testsudopwd(dlg.pwd):
                self.logwrite("Bad password entered. Try Again", gui.LOG_ERR)
                dlg = gui.PasswordDialog(self)
            return dlg.pwd
        except AttributeError:
            return None  # canceled

if __name__ == '__main__':
    t = Tix.Tk()
    t.option_add('*foreground', 'blue')  # normal fg color
    t.option_add('*background', 'black')  # normal bg color
    t.option_add('*activeBackground', 'black')  # bg on mouseover
    t.option_add('*activeForeground', 'blue')  # fg on mouseover
    t.option_add('*disabledForeground', 'gray')  # fg on disabled widget
    t.option_add('*disabledBackground', 'gray')  # bg on disabled widget
    t.option_add('*troughColor', 'black')  # trough on scales/scrollbars
    WraithPanel(t).mainloop()
Exemplo n.º 20
0
    def view_memory(self):
        self.message("You are now setting memory information")
        if self.memory_once == 1:
            self.memory_ok()
            return

        top = self.skyeye_body("Cpu & Mainboard")

        mem = Tix.Frame(top)

        b = Tix.Label(mem, text="Map  :")
        map = Tix.OptionMenu(mem, command=self.memory_map)
        b.grid(row=0, column=0, padx=5, pady=3, sticky=W + E)
        map.grid(row=0, column=1, columnspan=2, padx=5, pady=3, sticky=W + E)

        b = Tix.Label(mem, text="Type :")
        type = Tix.OptionMenu(mem, command=self.memory_type)
        b.grid(row=1, column=0, padx=5, pady=3, sticky=W + E)
        type.grid(row=1, column=1, columnspan=2, padx=5, pady=3, sticky=W + E)

        b = Tix.Label(mem, text="'Addr :")
        addr = Tix.ComboBox(mem,
                            editable=1,
                            history=1,
                            anchor=Tix.E,
                            command=self.memory_addr)
        b.grid(row=2, column=0, padx=5, pady=3, sticky=W + E)
        addr.grid(row=2, column=1, columnspan=2, padx=5, pady=3, sticky=W + E)

        b = Tix.Label(mem, text="Size :")
        size = Tix.ComboBox(mem,
                            editable=1,
                            history=1,
                            anchor=Tix.E,
                            command=self.memory_size)
        b.grid(row=3, column=0, padx=5, pady=3, sticky=W + E)
        size.grid(row=3, column=1, columnspan=2, padx=5, pady=3, sticky=W + E)

        b = Tix.Label(mem, text="File :")
        file = Tix.FileEntry(mem, command=self.memory_file)
        b.grid(row=4, column=0, padx=5, pady=3, sticky=W + E)
        file.grid(row=4, column=1, columnspan=2, padx=5, pady=3, sticky=W + E)

        add = Tix.Button(top, text="Add", command=self.memory_add)
        reset = Tix.Button(top, text="Reset", command=self.memory_reset)
        ok = Tix.Button(top, text="OK", command=self.memory_ok)

        map.add_command("I", label="I")
        map.add_command("M", label="M")

        type.add_command("R", label="R")
        type.add_command("W", label="W")
        type.add_command("RW", label="RW")

        addr.insert(Tix.END, "0x00000000")

        size.insert(Tix.END, "0x00000000")

        mem.grid(row=0,
                 column=0,
                 columnspan=3,
                 padx=5,
                 pady=10,
                 sticky=N + S + W + E)
        add.grid(row=1, column=0, padx=5, pady=10, sticky=W + E)
        reset.grid(row=1, column=1, padx=5, pady=10, sticky=W + E)
        ok.grid(row=1, column=2, padx=5, pady=10, sticky=W + E)

        self.skyeye_redobody()
Exemplo n.º 21
0
    def _makemenu(self):
        """ make the menu """
        self.menubar = Tix.Menu(self)

        # Wraith Menu
        # all options will always be enabled
        self.mnuWraith = Tix.Menu(self.menubar, tearoff=0)
        self.mnuWraithGui = Tix.Menu(self.mnuWraith, tearoff=0)
        self.mnuWraithGui.add_command(label='Save', command=self.guisave)
        self.mnuWraithGui.add_command(label='Load', command=self.guiload)
        self.mnuWraith.add_cascade(label='Gui', menu=self.mnuWraithGui)
        self.mnuWraith.add_separator()
        self.mnuWraith.add_command(label='Configure',
                                   command=self.configwraith)
        self.mnuWraith.add_separator()
        self.mnuWraith.add_command(label='Exit', command=self.delete)

        # Tools Menu
        # all options will always be enabled
        self.mnuTools = Tix.Menu(self.menubar, tearoff=0)
        self.mnuTools.add_command(label='Convert', command=self.viewconvert)
        self.mnuToolsCalcs = Tix.Menu(self.mnuTools, tearoff=0)
        self.mnuToolsCalcs.add_command(label='EIRP',
                                       command=lambda: self.calc('EIRP'))
        self.mnuToolsCalcs.add_command(label='FSPL',
                                       command=lambda: self.calc('FSPL'))
        self.mnuToolsCalcs.add_command(
            label='Link Budget', command=lambda: self.calc('Link Budget'))
        self.mnuTools.add_cascade(label='Calcuators', menu=self.mnuToolsCalcs)

        # View Menu
        # all options will always be enabled
        self.mnuView = Tix.Menu(self.menubar, tearoff=0)
        self.mnuView.add_command(label='Data Bins', command=self.viewdatabins)
        self.mnuView.add_separator()
        self.mnuView.add_command(label='Data', command=self.viewdata)

        # Storage Menu
        self.mnuStorage = Tix.Menu(self.menubar, tearoff=0)
        self.mnuStorage.add_command(label="Start All",
                                    command=self.storagestart)  # 0
        self.mnuStorage.add_command(label="Stop All",
                                    command=self.storagestop)  # 1
        self.mnuStorage.add_separator()  # 2
        self.mnuStoragePSQL = Tix.Menu(self.mnuStorage, tearoff=0)
        self.mnuStoragePSQL.add_command(label='Start',
                                        command=self.psqlstart)  # 0
        self.mnuStoragePSQL.add_command(label='Stop',
                                        command=self.psqlstop)  # 1
        self.mnuStoragePSQL.add_separator()  # 2
        self.mnuStoragePSQL.add_command(label='Connect',
                                        command=self.connect)  # 3
        self.mnuStoragePSQL.add_command(label='Disconnect',
                                        command=self.disconnect)  # 4      # 1
        self.mnuStoragePSQL.add_separator()  # 5
        self.mnuStoragePSQL.add_command(label='Fix', command=self.psqlfix)  # 6
        self.mnuStoragePSQL.add_command(label='Delete All',
                                        command=self.psqldelall)  # 7
        self.mnuStorage.add_cascade(label='PostgreSQL',
                                    menu=self.mnuStoragePSQL)  # 3
        self.mnuStorageNidus = Tix.Menu(self.mnuStorage, tearoff=0)
        self.mnuStorageNidus.add_command(label='Start',
                                         command=self.nidusstart)  # 0
        self.mnuStorageNidus.add_command(label='Stop',
                                         command=self.nidusstop)  # 1
        self.mnuStorageNidus.add_separator()  # 2
        self.mnuNidusLog = Tix.Menu(self.mnuStorageNidus, tearoff=0)
        self.mnuNidusLog.add_command(label='View',
                                     command=self.viewniduslog)  # 0
        self.mnuNidusLog.add_command(label='Clear',
                                     command=self.clearniduslog)  # 1
        self.mnuStorageNidus.add_cascade(label='Log',
                                         menu=self.mnuNidusLog)  # 3
        self.mnuStorageNidus.add_separator()  # 4
        self.mnuStorageNidus.add_command(label='Config',
                                         command=self.confignidus)  # 5
        self.mnuStorage.add_cascade(label='Nidus',
                                    menu=self.mnuStorageNidus)  # 4

        # DySKT Menu
        self.mnuDySKT = Tix.Menu(self.menubar, tearoff=0)
        self.mnuDySKT.add_command(label='Start', command=self.dysktstart)  # 0
        self.mnuDySKT.add_command(label='Stop', command=self.dysktstop)  # 1
        self.mnuDySKT.add_separator()  # 2
        self.mnuDySKT.add_command(label='Control',
                                  command=self.dysktctrl)  # 3            # 3
        self.mnuDySKT.add_separator()  # 4
        self.mnuDySKTLog = Tix.Menu(self.mnuDySKT, tearoff=0)
        self.mnuDySKTLog.add_command(label='View',
                                     command=self.viewdysktlog)  # 0
        self.mnuDySKTLog.add_command(label='Clear',
                                     command=self.cleardysktlog)  # 1
        self.mnuDySKT.add_cascade(label='Log', menu=self.mnuDySKTLog)  # 5
        self.mnuDySKT.add_separator()  # 6
        self.mnuDySKT.add_command(label='Config',
                                  command=self.configdyskt)  # 7

        # Help Menu
        self.mnuHelp = Tix.Menu(self.menubar, tearoff=0)
        self.mnuHelp.add_command(label='About', command=self.about)
        self.mnuHelp.add_command(label='Help', command=self.help)

        # add the menus
        self.menubar.add_cascade(label='Wraith', menu=self.mnuWraith)
        self.menubar.add_cascade(label="Tools", menu=self.mnuTools)
        self.menubar.add_cascade(label='View', menu=self.mnuView)
        self.menubar.add_cascade(label='Storage', menu=self.mnuStorage)
        self.menubar.add_cascade(label='DySKT', menu=self.mnuDySKT)
        self.menubar.add_cascade(label='Help', menu=self.mnuHelp)
Exemplo n.º 22
0
    def execute_run(self):
        top = self.skyeye_body("Start running skyeye")

        tmp = Tix.Frame(top, padx=10, pady=15)

        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=240,
                        anchor=Tix.N,
                        text='Below are the command to skyeye:')
        b.grid(row=0, padx=5, pady=15, sticky=W + E)
        tmp.grid(row=0, column=0, padx=5, pady=15, sticky=W + E)

        tmp = Tix.Frame(top, padx=10, pady=15)
        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='skyeye')
        b.grid(row=0, column=0, padx=5, pady=3, sticky=W + E)
        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='-e')
        b.grid(row=0, column=1, padx=5, pady=3, sticky=W + E)
        b = Tix.Message(tmp,
                        relief=Tix.FLAT,
                        width=440,
                        anchor=Tix.N,
                        text='-c')
        b.grid(row=1, column=1, padx=5, pady=3, sticky=W + E)
        self.image_path = Tix.Message(tmp,
                                      relief=Tix.FLAT,
                                      width=440,
                                      anchor=Tix.N,
                                      text='vmlinux')
        self.image_path.grid(row=0, column=2, padx=5, pady=3, sticky=W)
        self.conf_path = Tix.Message(tmp,
                                     relief=Tix.FLAT,
                                     width=440,
                                     anchor=Tix.N,
                                     text='skyeye.conf')
        self.conf_path.grid(row=1, column=2, padx=5, pady=3, sticky=W)

        file = Tix.FileEntry(tmp, command=self.image_path_do)
        file.grid(row=0, column=3, padx=5, pady=3, sticky=W + E)
        file = Tix.FileEntry(tmp, command=self.conf_path_do)
        file.grid(row=1, column=3, padx=5, pady=3, sticky=W + E)

        tmp.grid(row=1, column=0, padx=5, pady=10, sticky=W + E)

        tmp = Tix.Frame(top, padx=10, pady=15)

        tmp.grid(row=2, column=0, padx=5, pady=10, sticky=W + E)

        self.run = Tix.Button(tmp, text="Run", command=self.run_skyeye)
        self.kill = Tix.Button(tmp, text="Kill", command=self.kill_skyeye)
        self.kill.config(state=DISABLED)

        self.run.grid(row=0, column=0, padx=5, pady=3, sticky=W + E)
        self.kill.grid(row=0, column=1, padx=5, pady=3, sticky=W + E)

        self.skyeye_redobody()
Exemplo n.º 23
0
    def __init__(self, w):
        self.root = w
        self.exit = -1

        global demo_maker, demo_thrust, demo_num_engines

        demo_maker = Tix.StringVar()
        demo_thrust = Tix.DoubleVar()
        demo_num_engines = Tix.IntVar()
        demo_maker.set('P&W')
        demo_thrust.set(20000.0)
        demo_num_engines.set(2)

        top = Tix.Frame(w, bd=1, relief=Tix.RAISED)

        # $w.top.a allows only integer values
        #
        # [Hint] The -options switch sets the options of the subwidgets.
        # [Hint] We set the label.width subwidget option of the Controls to
        #        be 16 so that their labels appear to be aligned.
        #
        a = Tix.Control(top,
                        label='Number of Engines: ',
                        integer=1,
                        variable=demo_num_engines,
                        min=1,
                        max=4,
                        options='entry.width 10 label.width 20 label.anchor e')

        b = Tix.Control(top,
                        label='Thrust: ',
                        integer=0,
                        min='10000.0',
                        max='60000.0',
                        step=500,
                        variable=demo_thrust,
                        options='entry.width 10 label.width 20 label.anchor e')

        c = Tix.Control(top,
                        label='Engine Maker: ',
                        value='P&W',
                        variable=demo_maker,
                        options='entry.width 10 label.width 20 label.anchor e')

        # We can't define these in the init because the widget 'c' doesn't
        # exist yet and we need to reference it
        c['incrcmd'] = lambda w=c: adjust_maker(w, 1)
        c['decrcmd'] = lambda w=c: adjust_maker(w, -1)
        c['validatecmd'] = lambda w=c: validate_maker(w)

        a.pack(side=Tix.TOP, anchor=Tix.W)
        b.pack(side=Tix.TOP, anchor=Tix.W)
        c.pack(side=Tix.TOP, anchor=Tix.W)

        box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
        box.add('ok', text='Ok', underline=0, width=6, command=self.okcmd)
        box.add('cancel',
                text='Cancel',
                underline=0,
                width=6,
                command=self.quitcmd)
        box.pack(side=Tix.BOTTOM, fill=Tix.X)
        top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Exemplo n.º 24
0
    def __new__(self,*args,**kwargs):#We use __new__ instead of __init__ so we can return None if the user clicks cancel
        ''' Build and show a GUI dialog to collect arguments
            @type  args:        C{list of L{Arg}s}
            @param args:        One or more C{L{Arg}s}.
            @type    title:     C{str}
            @keyword title:     Window title.
            @type    icon:      C{L{icons}}
            @keyword icon:      An icon class from the L{icons} module.
            @type    callback:  C{U{callable<http://docs.python.org/library/functions.html#callable>} object}
            @keyword callback:  A function/class that is called when the OK button is clicked.
                                No positional/keyword arguments are supported (unless the L{Command} class is used).

            @rtype:  C{GetArgs}
            @return:  C{GetArgs}

            @see: L{runcrawler} for an example.
        '''
        try:import Tix
        except:return None

        self=object.__new__(self)

        title=kwargs.get('title','Arguments')
        icon=kwargs.get('icon',None)

        self._root = Tix.Tk()
        self._root.withdraw()
        self._root.title(title)

        if icon is not None:
            self.icon=Tix.PhotoImage(data=icon.data,format=icon.format)
            try:self._root.tk.call('wm', 'iconphoto', self._root._w, self.icon)
            except:pass

        #On Ok callback
        self._callback=lambda *a,**kw:True #default
        self.callback=kwargs.get('callback',self._callback)

        # Calculate the geometry to centre the app
        scrnWt = self._root.winfo_screenwidth()
        scrnHt = self._root.winfo_screenheight()
        appWt = self._root.winfo_width()
        appHt = self._root.winfo_height()
        appXPos = (scrnWt / 2) - (appWt / 2)
        appYPos = (scrnHt / 2) - (appHt / 2)
        self._root.geometry('+%d+%d' % (appXPos, appYPos))
        initialdir=''
        self._lastdir = Tix.StringVar(self._root,initialdir)

        self._args={}
        self._objs={}
        for i,arg in enumerate(args):
            argname=arg.opt.dest
            if 'initialdir' in vars(arg) and not arg.initialdir:
                arg.lastdir=self._lastdir
            arg.__build__(self._root,i)
            self._args[argname]=arg

        nargs=len(self._args)
        self._root.bind("<Return>", self._cmdok)
        self._root.protocol("WM_DELETE_WINDOW", self._cmdcancel)
        TkFrame=Tix.Frame(self._root)
        TkFrame.grid(row=nargs,columnspan=3,sticky=Tix.E)
        bOK = Tix.Button(TkFrame,text="Ok", command=self._cmdok)
        bOK.config(width=8)
        bOK.grid(row=0, column=1,sticky=Tix.E, padx=5,pady=5)
        bCancel = Tix.Button(TkFrame,text="Cancel", command=self._cmdcancel)
        bCancel.config(width=8)
        bCancel.grid(row=0, column=2,sticky=Tix.E, padx=5,pady=5)

        self._cancelled = False

        self._root.deiconify()
        self._root.mainloop()
        if self._cancelled:return None
        else:return self
Exemplo n.º 25
0
import Tix as Tk
root = Tk.Tk()


def command_print():
    print box.cget("value")


box = Tk.FileSelectBox(root)
box.config(directory="c:\\")
box.pack()
Tk.Button(root, text="print", command=command_print).pack()

root.mainloop()
Exemplo n.º 26
0
def RunSample(w):
    global demo_month, demo_year

    top = Tix.Frame(w, bd=1, relief=Tix.RAISED)

    demo_month = Tix.StringVar()
    demo_year = Tix.StringVar()

    # $w.top.a is a drop-down combo box. It is not editable -- who wants
    # to invent new months?
    #
    # [Hint] The -options switch sets the options of the subwidgets.
    # [Hint] We set the label.width subwidget option of both comboboxes to
    #        be 10 so that their labels appear to be aligned.
    #
    a = Tix.ComboBox(top,
                     label="Month: ",
                     dropdown=1,
                     command=select_month,
                     editable=0,
                     variable=demo_month,
                     options='listbox.height 6 label.width 10 label.anchor e')

    # $w.top.b is a non-drop-down combo box. It is not editable: we provide
    # four choices for the user, but he can enter an alternative year if he
    # wants to.
    #
    # [Hint] Use the padY and anchor options of the label subwidget to
    #        align the label with the entry subwidget.
    # [Hint] Notice that you should use padY (the NAME of the option) and not
    #        pady (the SWITCH of the option).
    #
    b = Tix.ComboBox(
        top,
        label="Year: ",
        dropdown=0,
        command=select_year,
        editable=1,
        variable=demo_year,
        options='listbox.height 4 label.padY 5 label.width 10 label.anchor ne')

    a.pack(side=Tix.TOP, anchor=Tix.W)
    b.pack(side=Tix.TOP, anchor=Tix.W)

    a.insert(Tix.END, 'January')
    a.insert(Tix.END, 'February')
    a.insert(Tix.END, 'March')
    a.insert(Tix.END, 'April')
    a.insert(Tix.END, 'May')
    a.insert(Tix.END, 'June')
    a.insert(Tix.END, 'July')
    a.insert(Tix.END, 'August')
    a.insert(Tix.END, 'September')
    a.insert(Tix.END, 'October')
    a.insert(Tix.END, 'November')
    a.insert(Tix.END, 'December')

    b.insert(Tix.END, '1992')
    b.insert(Tix.END, '1993')
    b.insert(Tix.END, '1994')
    b.insert(Tix.END, '1995')
    b.insert(Tix.END, '1996')

    # Use "tixSetSilent" to set the values of the combo box if you
    # don't want your -command procedures (cbx:select_month and
    # cbx:select_year) to be called.
    #
    a.set_silent('January')
    b.set_silent('1995')

    box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
    box.add('ok',
            text='Ok',
            underline=0,
            width=6,
            command=lambda w=w: ok_command(w))
    box.add('cancel',
            text='Cancel',
            underline=0,
            width=6,
            command=lambda w=w: w.destroy())
    box.pack(side=Tix.BOTTOM, fill=Tix.X)
    top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
Exemplo n.º 27
0
    def _hlistKw(self, model, colNum):
        vt = _valueTypes[self.columnMap[colNum]]
        vf = _valueFuncs[self.columnMap[colNum]]
        kw = {'itemtype': vt}
        txt = None
        img = None
        if vt == 'text':
            txt = vf(model)
            if not isinstance(txt, basestring):
                txt, bcolor = txt
                if bcolor is not None:
                    if not isinstance(bcolor, basestring):
                        if hasattr(bcolor, 'rgba'):
                            rgba = bcolor.rgba()
                        else:
                            rgba = bcolor
                        from CGLtk.color import rgba2tk
                        bcolor = rgba2tk(rgba)
                        fcolor = CGLtk.textForeground(bcolor, self.modelTable)
                    kw['style'] = Tix.DisplayStyle("text",
                                                   refwindow=self.modelTable,
                                                   background=bcolor,
                                                   foreground=fcolor,
                                                   selectforeground=bcolor)
            else:
                kw['style'] = self.textStyle
        elif vt == 'image':
            img = vf(model)
        elif vt == 'imagetext':
            img, txt = vf(model)
        elif vt == 'toggle':
            kw['itemtype'] = 'window'
            bool, cb = vf(model)
            togKw = {
                'command':
                # avoid holding references to model
                lambda cb=cb, i=self.models.index(model), b=not bool: cb(
                    self.models[i], b),
                'indicatoron':
                0,
                'borderwidth':
                0
            }
            if bool:
                togKw['image'] = self.modelTable.tk.call(
                    'tix', 'getimage', 'ck_on')
            else:
                togKw['image'] = self.modelTable.tk.call(
                    'tix', 'getimage', 'ck_off')
            toggle = Tkinter.Checkbutton(self.modelTable.hlist, **togKw)
            kw['window'] = toggle
            kw['style'] = self.checkButtonStyle
        elif vt == 'well':
            color, noneOkay, alphaOkay, cb = vf(model)
            if color is False:
                kw['itemtype'] = 'text'
                txt = ""
            else:
                kw['itemtype'] = 'window'
                if isinstance(color, chimera.MaterialColor):
                    color = color.rgba()

                def wellCB(clr, cb=cb, mdl=model):
                    if clr is not None:
                        clr = chimera.MaterialColor(*clr)
                    cb(mdl, clr)

                from CGLtk.color.ColorWell import ColorWell
                kw['window'] = ColorWell(self.modelTable.hlist,
                                         color,
                                         callback=wellCB,
                                         width=18,
                                         height=18,
                                         noneOkay=noneOkay,
                                         wantAlpha=alphaOkay)
                kw['style'] = self.colorWellStyle
        else:
            raise ValueError("Unknown column type: '%s'" % vt)

        if txt != None:
            kw['text'] = str(txt)
        if img != None:
            kw['image'] = self.modelTable.tk.call('tix', 'getimage', img)
        return kw
Exemplo n.º 28
0
    def __draw_complex_var(self, canvas, item, **args):
        """显示一个结构体或者数组。

        结构体的孩子有两种类型:

        一是简单变量,一是结构体。

        两种类型都需要增加下列标签:

        tags = ( key, varname, 'tag_%s' % key)

        其中前面两个用来修改变量的值,后面用来定位和移动孩子结点。

        """
        name = args.get("name", "")
        text = item["value"]
        tname = item["type"]
        assert(tname in ("Array", "Record"))
        assert(isinstance(text, basestring) and text)
        data = eval(text, {}, self.master.items)
        assert(isinstance(data, dict))
        if len(data) == 0:
            return
        anonymous = args.get("anonymous", False)
        orientation = args.get("orientation", "horizontal")
        width = args.get("width", 40)
        height = args.get("height", 40)
        shape = args.get("shape", "oval")
        x = args.get("x", 0)
        y = args.get("y", 0)
        padx = args.get("padx", 2)
        pady = args.get("pady", 2)
        xincrement = args.get("xincrement", 0)
        yincrement = args.get("yincrement", 0)
        anchor = args.get("anchor", "nw")

        # 计算开始的填充宽度

        title_height = 20
        # 内置填充宽度
        ipadx = 2
        ipady = 2

        # 排序孩子元素
        klist = data.keys()
        if tname == "Array":
            klist.sort(lambda x,y: cmp(int(x), int(y)))
        else:
            klist.sort()
        n = len(klist)

        # 计算自身范围: x1, y1, x2, y2
        if canvas.winfo_viewable():
            canvas_width = canvas.winfo_width()
            canvas_height = canvas.winfo_height()
        else:
            canvas_width = canvas.winfo_reqwidth()
            canvas_height = canvas.winfo_reqheight()

        if orientation == "horizontal":
            x1 = x
            y1 = y
            x2 = canvas_width - x
            if height:
                y2 = y + height
            else:
                y2 = canvas_height - y

        else:
            x1 = x
            y1 = y
            if width:
                x2 = x + width
            else:
                x2 = canvas_width - x
            y2 = canvas_height - y
        y2 -= title_height
        assert(x1 >= 0 and x2 >= 0 and y1 >= 0 and y2 >= 0)
        assert(x1 < x2 and y1 < y2)

        x = x1 + ipadx + padx
        y = y1 + ipady + pady
        if width < 40: width = 40
        if height < 40: height = 40

        offset = 0
        xoffset = 0
        yoffset = 0
        for i in range(n):
            k = klist[i]
            v = data[k]
            if v is None:
                continue

            if orientation == "horizontal":
                if yincrement > 0:
                    yoffset = (n - i - 1) * yincrement
                else:
                    yoffset = - i * yincrement
            else:
                if xincrement > 0:
                    xoffset = (n - i - 1) * xincrement
                else:
                    xoffset = - i * xincrement

            assert(isinstance(v, dict))
            if v["type"] in ("Array", "Record", "Tree"):
                varname = v[0]
                child_frame = Tix.Frame(canvas)
                child_options = self.master.items[varname]
                child_canvas = Tix.Canvas(
                    child_frame,
                    highlightthickness=0,
                    width=_width,
                    height=_height,
                    )
                child_canvas.grid(sticky="nesw")
                canvas.create_window(
                    x + xoffset,
                    y + yoffset,
                    window=child_frame,
                    anchor="nw",
                    tags=(k, name, "tag_%s" % k),
                    )
                # 还需要判断是否是树还是结构体
                r = self.__draw_complex_var(
                    child_canvas,
                    v,
                    name=k,
                    x=0,
                    y=0,
                    **child_options
                    )
                # 重新设置宽度和高度
                child_canvas.configure(
                    width=r[2],
                    height=r[3],
                    )

            else:
                if anonymous:
                    title = None
                else:
                    title = k
                text = v["value"]
                r = self.__draw_simple_var(
                    canvas,
                    tags=(k, name, "tag_%s" % k),
                    title=title,
                    text=text,
                    x=x + xoffset,
                    y=y + yoffset,
                    width=width,
                    height=height,
                    shape=shape,
                    )
            if orientation == "horizontal":
                x += r[2]
                if offset < r[3]: offset = r[3]
            else:
                y += r[3]
                if offset < r[2]: offset = r[2]
            width += 2 * xincrement
            height += 2 * yincrement


        # 根据孩子的实际尺寸调整自身的尺寸
        # 计算尺寸:x1, y1, x2, y2
        # 实际坐标,x, y
        if orientation == "horizontal":
            xr = x
            yr = y + offset
        else:
            xr = x + offset
            yr = y

        # 修改终点值
        x2 = xr + ipadx + padx
        y2 = yr + ipady + pady
        xmount, ymount = self.__get_child_offset(
            anchor,
            (xr, yr),
            (x1, y1, x2, y2),
            (ipadx + padx, ipady + pady),
            )
        if xmount or ymount:
            for k in klist:
                canvas.move("tag_%s" % k, xmount, ymount)

        canvas.create_rectangle(
            x1 + ipadx,
            y1 + ipady,
            x2 - ipadx,
            y2 - ipady,
            )
        canvas.create_text(
            (x1 + x2) / 2,
            y2 + ipady,
            anchor="n",
            text=name,
            )
        return (x1, y1, x2 - x1, y2 - y1 + title_height)
Exemplo n.º 29
0
#!/usr/local/bin/python
Exemplo n.º 30
0
    def __create_property_window(self, frame):
        _soptions = ("label.width 15 label.anchor e label.relief flat "
                     "menubutton.width 15 menubutton.relief groove")
        _coptions = ("label.width 16 label.anchor e "
                     "entry.width 20 relief groove "
                     "decr.relief flat incr.relief flat ")
        _eoptions = ("label.width 16 label.anchor e "
                     "entry.width 20 relief groove")

        boolean_list = ("False", "True")

        v = Tix.StringVar()
        self.var_list["type"] = v

        v = Tix.StringVar()
        self.var_list["value"] = v

        v = Tix.IntVar()
        self.var_list["visible"] = v

        v = Tix.IntVar()
        self.var_list["width"] = v

        v = Tix.IntVar()
        self.var_list["height"] = v

        v = Tix.StringVar()
        self.var_list["orientation"] = v

        v = Tix.IntVar()
        self.var_list["padx"] = v

        v = Tix.IntVar()
        self.var_list["pady"] = v

        v = Tix.IntVar()
        self.var_list["xincrement"] = v

        v = Tix.IntVar()
        self.var_list["yincrement"] = v

        v = Tix.StringVar()
        self.var_list["shape"] = v

        v = Tix.StringVar()
        self.var_list["anchor"] = v

        v = Tix.IntVar()
        self.var_list["anonymous"] = v

        v = Tix.IntVar()
        self.var_list["size"] = v

        w = Tix.OptionMenu(
            frame,
            label=_("Type:"),
            options=_soptions,
            )
        for opt in TYPE_LIST:
            w.add_command(opt, label=opt)
        w.configure(variable=self.var_list["type"])
        w.grid(sticky="wen")

        w = Tix.LabelEntry(
            frame,
            label=_("Value:"),
            options=_eoptions,
            )
        w.entry.config(
            textvariable=self.var_list["value"],
            )
        # w.grid(sticky="wen")

        w = Tix.Text(
            frame,
            width=40,
            height=10,
            state="disabled",
            )
        # w.grid(pady=2, sticky="nesw")
        self.value_text = w

        w = Tix.OptionMenu(
            frame,
            label=_("Visible:"),
            options=_soptions,
            )
        for i in (0, 1):
            w.add_command(str(i), label=boolean_list[i])
        w.configure(variable=self.var_list["visible"])
        w.grid(sticky="wen")

        _option_list = ("oval", "renctangle")
        _w = Tix.OptionMenu(
            frame,
            label=_("Shape:"),
            variable=self.var_list["shape"],
            options=_soptions,
            )
        for _opt in _option_list:
            _w.add_command(_opt, label=_opt)
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Width:"),
            integer=1,
            variable=self.var_list["width"],
            min=40,
            max=1024,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Heigth:"),
            integer=1,
            variable=self.var_list["height"],
            min=40,
            max=1024,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Array Size:"),
            integer=1,
            variable=self.var_list["size"],
            min=0,
            max=100,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Padx:"),
            integer=1,
            variable=self.var_list["padx"],
            min=0,
            max=100,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Pady:"),
            integer=1,
            variable=self.var_list["pady"],
            min=0,
            max=100,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Xincrement:"),
            integer=1,
            variable=self.var_list["xincrement"],
            min=-100,
            max=100,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        _w = Tix.Control(
            frame,
            label=_("Yincrement:"),
            integer=1,
            variable=self.var_list["yincrement"],
            min=-100,
            max=100,
            options=_coptions,
            )
        _w.grid(sticky="wen")

        w = Tix.OptionMenu(
            frame,
            label=_("Anonymous:"),
            options=_soptions,
            )
        for i in (0, 1):
            w.add_command(str(i), label=boolean_list[i])
        w.configure(variable=self.var_list["anonymous"])
        w.grid(sticky="wen")
        
        _option_list = ("horizontal", "vertical")
        _w = Tix.OptionMenu(
            frame,
            label=_("Orientation:"),
            variable=self.var_list["orientation"],
            options=_soptions,
            )
        for _opt in _option_list:
            _w.add_command(_opt, label=_opt)
        _w.grid(sticky="wen")

        _option_list = ("n", "ne", "e", "se", "s", "sw", "w", "nw", "center")
        _w = Tix.OptionMenu(
            frame,
            label=_("Anchor:"),
            variable=self.var_list["anchor"],
            options=_soptions,
            )
        for _opt in _option_list:
            _w.add_command(_opt, label=_opt)
        _w.grid(sticky="wen")

        # 设定默认值以及变更跟踪
        for k, v in self.var_list.iteritems():
            v.set(self.empty_item[k])
            if k == "size":
                v.trace_variable("w", self.__change_array_size)
            else:
                v.trace_variable("w", lambda i,v,m,k=k:self.__change_option_value(k))
Exemplo n.º 31
0
#-----------------------------------------------------------------------------
# Copyright (c) 2013-2021, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License (version 2
# or later) with exception for distributing the bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#
# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
#-----------------------------------------------------------------------------


import Tix as tix

root = tix.Tk()
root.title("Test for TiX")

tix.Label(text="Press <ESC> to exit").pack()
tix.DirList(root).pack()
tix.Button(root, text="Close", command=root.destroy).pack()
root.bind("<Escape>", lambda x: root.destroy())

tix.mainloop()
Exemplo n.º 32
0
 def file_openfile(self):
     tmp = Tix.ExFileSelectBox(self.skyeye_body("Open file for reading"),
                               command=self.file_openfile_command)
     tmp.pack(fill=Tix.BOTH, padx=8, pady=20)
     self.skyeye_redobody()
Exemplo n.º 33
0
 def welcome(self):
     tmp = Tix.Label(self.skyeye_body("Welcome"),
                     text="koodialar",
                     height=30)
     tmp.pack(fill=Tix.BOTH, padx=8, pady=20)
     self.skyeye_redobody()
Exemplo n.º 34
0
###
import Tix as tk
from pshout import pprint

r= tk.Tk()
r.title("test")

l=tk.Label(r, name="a_label")
l.pack()

class MyGrid(tk.Grid):
    def __init__(self, *args, **kwargs):
        kwargs['editnotify']= self.editnotify
        tk.Grid.__init__(self, *args, **kwargs)
    def editnotify(self, x, y):
        return True

g = MyGrid(r, name="a_grid",
selectunit="cell")
g.pack(fill=tk.BOTH)
for x in xrange(5):
    for y in xrange(5):
        g.set(x,y,text=str((x,y)))

c = tk.Button(r, text="Close", command=r.destroy)
c.pack()

tk.mainloop()
Exemplo n.º 35
0
    def update_scales():
        levels = tl.get_levels()
        for color in colors:
            scalevars[color].set(levels.get(color, 0))

    colorscalesframe.pack()
    time_scale = Tix.Scale(root, from_=0, to_=tl.length(), orient=Tix.HORIZONTAL, res=0.01, command=set_timeline_time)
    time_scale.pack(side=Tix.BOTTOM, fill=Tix.X, expand=1)

    def play_tl():
        tl.tick()
        update_scales()
        time_scale.set(tl.current_time)
        # print 'time_scale.set', tl.current_time
        root.after(10, play_tl)

    controlwindow = Tix.Toplevel()
    Tix.Button(controlwindow, text="Stop", command=lambda: tl.stop()).pack(side=Tix.LEFT)
    Tix.Button(controlwindow, text="Play", command=lambda: tl.play()).pack(side=Tix.LEFT)
    Tix.Button(controlwindow, text="Reset", command=lambda: time_scale.set(0)).pack(side=Tix.LEFT)
    Tix.Button(controlwindow, text="Flip directions", command=lambda: tl.reverse_direction()).pack(side=Tix.LEFT)
    Tix.Button(controlwindow, text="1/2x", command=lambda: tl.set_rate(0.5 * tl.rate)).pack(side=Tix.LEFT)
    Tix.Button(controlwindow, text="2x", command=lambda: tl.set_rate(2 * tl.rate)).pack(side=Tix.LEFT)

    root.after(100, play_tl)

    # Timeline.set_time = trace(Timeline.set_time)

    Tix.mainloop()