Exemplo n.º 1
0
    def __init__(self,
                 master,
                 values,
                 command=None,
                 args=(),
                 variable=None,
                 **kw):

        kw['style'] = 'TComboSmall'
        if variable is not None:
            kw['textvariable'] = variable
        self.variable = variable
        WidgetWithCommand.__init__(self)
        Widget.__init__(self, master, "ttk::menubutton", kw)
        if command:
            self.set_command(command, args)

        entries = []
        for value in values:
            entries.append(
                ComboCommand(value, command=self.choose_opt, args=value))

        self.__menu = ComboMenu(self,
                                entries,
                                auto_update=0,
                                name="menu",
                                tearoff=0)

        menu = self.__menu.menu
        self.menuname = menu._w
        self["menu"] = menu
Exemplo n.º 2
0
    def __init__(self, master, values, command = None, args = (),
		 entry_type = 'text', **rest):
	kw = option_menu_defaults.copy()
	kw.update(rest)
	WidgetWithCommand.__init__(self)
	Widget.__init__(self, master, "menubutton", kw)
	self.widgetName = 'tk_optionMenu'
	if command:
	    self.set_command(command, args)

	entries = []
	value_dict = {}
	cfg = {'command' : self.choose_opt}
	for value in values:
	    if type(value) == TupleType:
		text, value = value
	    else:
		text = value
	    value_dict[value] = text
	    if not rest.has_key('initial'):
		rest['initial'] = value

	    cfg[entry_type] = text
	    cfg['args'] = (value,)
	    entries.append(apply(MenuCommand, (), cfg))

	self.__menu = UpdatedMenu(self, entries, auto_update = 0,
				  name="menu", tearoff=0)
	menu = self.__menu.menu
	self.menuname = menu._w
	self["menu"] = menu
	self.entry_type = entry_type
	self.value_dict = value_dict
	if rest.has_key('initial'):
	    self.SetValue(rest['initial'])
Exemplo n.º 3
0
    def __init__(self, master, values, command = None, args = (),
                 entry_type = 'text', **rest):
        kw = option_menu_defaults.copy()
        kw.update(rest)
        WidgetWithCommand.__init__(self)
        Widget.__init__(self, master, "menubutton", kw)
        self.widgetName = 'tk_optionMenu'
        if command:
            self.set_command(command, args)

        entries = []
        value_dict = {}
        cfg = {'command' : self.choose_opt}
        for value in values:
            if type(value) == TupleType:
                text, value = value
            else:
                text = value
            value_dict[value] = text
            if not rest.has_key('initial'):
                rest['initial'] = value

            cfg[entry_type] = text
            cfg['args'] = (value,)
            entries.append(apply(MenuCommand, (), cfg))

        self.__menu = UpdatedMenu(self, entries, auto_update = 0,
                                  name="menu", tearoff=0)
        menu = self.__menu.menu
        self.menuname = menu._w
        self["menu"] = menu
        self.entry_type = entry_type
        self.value_dict = value_dict
        if rest.has_key('initial'):
            self.SetValue(rest['initial'])
Exemplo n.º 4
0
 def __init__(self, master, variable, value, **kwargs):
     kw = {'borderwidth': 2, 'textvariable': variable,
           'indicatoron': 1, 'relief': RAISED, 'anchor': 'c',
           'highlightthickness': 2}
     Widget.__init__(self, master, 'menubutton', kw)
     self.var = variable
     self.widget_name = 'tk_optionmenu'
     self.__menu = Menu(self, name='menu', tearoff=0)
     self.menu_name = self.__menu._w
     self.callback = kwargs.get('command')
     if 'command' in kwargs:
         del kwargs['command']
     if kwargs:
         raise TclError('unknown option -' + kwargs.keys()[0])
     self.__menu.add_command(label=value,
                             command=_SetIt(variable, value, self.callback))
     self['menu'] = self.__menu
Exemplo n.º 5
0
	def __init__(self, master, values, command = None, args = (), variable = None, **kw):

		kw['style'] = 'TComboSmall'
		if variable is not None:
			kw['textvariable'] = variable
		self.variable = variable
		WidgetWithCommand.__init__(self)
		Widget.__init__(self, master, "ttk::menubutton", kw)
		if command:
			self.set_command(command, args)

		entries = []
		for value in values:
			entries.append(ComboCommand(value, command = self.choose_opt, args = value))
			
		self.__menu = ComboMenu(self, entries, auto_update = 0, name="menu", tearoff=0)

		menu = self.__menu.menu
		self.menuname = menu._w
		self["menu"] = menu
Exemplo n.º 6
0
    def __init__(self, master, values, command = None, args = (),
		 variable = None):
	kw = option_menu_defaults.copy()
	if variable is not None:
	    kw['textvariable'] = variable
	self.variable = variable
	WidgetWithCommand.__init__(self)
	Widget.__init__(self, master, "menubutton", kw)
	#self.widgetName = 'tk_optionMenu'
	if command:
	    self.set_command(command, args)

	entries = []
	for value in values:
	    entries.append(MenuCommand(value, command = self.choose_opt,
				       args = value))
	self.__menu = UpdatedMenu(self, entries, auto_update = 0,
				  name="menu", tearoff=0)
	menu = self.__menu.menu
	self.menuname = menu._w
	self["menu"] = menu
Exemplo n.º 7
0
    def __init__(self, master, values, command = None, args = (),
                 variable = None):
        kw = option_menu_defaults.copy()
        if variable is not None:
            kw['textvariable'] = variable
        self.variable = variable
        WidgetWithCommand.__init__(self)
        Widget.__init__(self, master, "menubutton", kw)
        #self.widgetName = 'tk_optionMenu'
        if command:
            self.set_command(command, args)

        entries = []
        for value in values:
            entries.append(MenuCommand(value, command = self.choose_opt,
                                       args = value))
        self.__menu = UpdatedMenu(self, entries, auto_update = 0,
                                  name="menu", tearoff=0)
        menu = self.__menu.menu
        self.menuname = menu._w
        self["menu"] = menu
Exemplo n.º 8
0
class WidgetTestCase(unittest.TestCase):
    def setUp(self):
        self.widget = Widget()
    def tearDown(self):
        self.widget.dispose()
        self.widget = None
    def testSize(self):
        self.assertEqual(self.widget.getSize(), (40, 40))
    def testResize(self):
        self.widget.resize(100, 100)        
        self.assertEqual(self.widget.getSize(), (100, 100))        
Exemplo n.º 9
0
class WidgetTestCase(unittest.TestCase):
    def setUp(self):
        self.widget = Widget()

    def tearDown(self):
        self.widget.dispose()
        self.widget = None

    def testSize(self):
        self.assertEqual(self.widget.getSize(), (40, 40))

    def testResize(self):
        self.widget.resize(100, 100)
        self.assertEqual(self.widget.getSize(), (100, 100))
Exemplo n.º 10
0
    def __init__(self, master=None, **kw):
	pax.register_object(self)
	kw['pyobject'] = id(self)
	kw['class'] = self.__class__.__name__
	Widget.__init__(self, master, 'paxwidget', kw = kw)
Exemplo n.º 11
0
 def _unregister_event_handlers(self):
     Widget.unbind(self._view.canvas, '<Button-1>')
Exemplo n.º 12
0
 def _unregister_event_handlers(self):
     Widget.unbind(self._view.canvas, '<Button-1>')
Exemplo n.º 13
0
 def _register_event_handlers(self):
     Widget.bind(self._view.canvas, '<Button-1>', self.mouse_click)
Exemplo n.º 14
0
 def __getitem__(self, name):
     if name == 'menu':
         return self.__menu.menu
     return Widget.__getitem__(self, name)
Exemplo n.º 15
0
	def __init__(self, master=None, **kw):
		key = pax.register_object(self)
		kw['pyobject'] = key
		kw['class'] = self.__class__.__name__
		Widget.__init__(self, master, 'paxwidget', kw=kw)
		self.InitTkWinObject(pax.name_to_window(self._w, self.tk.interpaddr()))
Exemplo n.º 16
0
 def _register_event_handlers(self):
     Widget.bind(self._view.canvas, '<Button-1>', self.mouse_click)
Exemplo n.º 17
0
 def __init__(self, master=None, **kw):
     key = pax.register_object(self)
     kw['pyobject'] = key
     kw['class'] = self.__class__.__name__
     Widget.__init__(self, master, 'paxwidget', kw = kw)
     self.InitTkWinObject(pax.name_to_window(self._w, self.tk.interpaddr()))
Exemplo n.º 18
0
# Getting the parent of a parent widget in Python Tkinter
parent = event.widget.winfo_parent()
from Tkinter import Widget
Widget._nametowidget(parent)
Exemplo n.º 19
0
 def setUp(self):
     self.widget = Widget()
Exemplo n.º 20
0
    def __getitem__(self, name):
	if name == 'menu':
	    return self.__menu.menu
	return Widget.__getitem__(self, name)
 def __init__(self, master=None, **kw):
     Widget.__init__(self, master, "ttk::combobox", kw)
     self.bind("<Key>", lambda e: "break")  # Magic
Exemplo n.º 22
0
 def setUp(self):
     self.widget = Widget()
Exemplo n.º 23
0
 def _unregister_event_handlers(self):
     if not isinstance(self._view.canvas, TrainingCanvas):
         Widget.unbind(self._view.canvas, '<Button-1>')