コード例 #1
0
    def __init__(self):
        HBox.__init__(self, False, 2)

        self.toolBox = VBox(False, 2)
        self.shapeCategoryCombo = DirCombo(join(data_path, 'shapes'))

        self.toolBox.pack_start(self.shapeCategoryCombo, False, False, 0)

        self.drawArea = DrawArea()

        root = self.drawArea.canvas.get_root_item()
        text = Text(text='Testing', x=200, y=200)
        rect = Rect(height=50,
                    width=100,
                    radius_x=10,
                    radius_y=10,
                    x=200,
                    y=500,
                    fill_color='gray')
        buttonText = Text(text='Button',
                          x=250,
                          y=525,
                          fill_color='dark-gray',
                          anchor=ANCHOR_CENTER)
        root.add_child(text, -1)
        root.add_child(rect, -1)
        root.add_child(buttonText, -1)

        self.pack_start(self.toolBox, False, False, 0)
        self.pack_start(self.drawArea, True, True, 0)
コード例 #2
0
ファイル: startslideshow.py プロジェクト: pborky/pyslides
 def __init__(self):
     from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator
     self.window =  Window(WINDOW_TOPLEVEL)
     self.window.set_title("Slideshow")
     self.window.connect("delete_event", self.delete_event)
     self.window.set_border_width(10)
     self.vbox = VBox(False, 0)
     self.window.add(self.vbox)
     self.hbox1 = HBox(False, 0)
     self.vbox.pack_start(self.hbox1, True, True, 1)
     self.hbox = HBox(False, 0)
     self.vbox.pack_start(self.hbox, False, False, 1)
     self.hbox2 = HBox(False, 0)
     self.vbox.pack_start(self.hbox2, True, True, 1)
     self.label = Label('Identifikační číslo:')
     self.hbox.pack_start(self.label, False, False, 1)
     self.label.show()
     self.editable = Entry()
     self.editable.connect('key_press_event', self.key_press_event)
     self.hbox.pack_start(self.editable, True, True, 1)
     self.editable.show()
     self.button = Button("Začít")
     self.button.connect("clicked", self.callback)
     self.button.set_receives_default(True)
     self.button.set_can_focus(True)
     self.hbox.pack_start(self.button, False, False, 1)
     self.button.show()
     self.hbox1.show()
     self.hbox.show()
     self.hbox2.show()
     self.vbox.show()
     self.window.show()
コード例 #3
0
class password_dialog(Dialog):
    
    def __init__(self, parent, icon):
        Dialog.__init__(self, "GtkPacman Login", parent,
                               DIALOG_MODAL | DIALOG_DESTROY_WITH_PARENT,
                           (STOCK_OK, RESPONSE_ACCEPT, STOCK_CANCEL, RESPONSE_REJECT))
        self.set_icon(pixbuf_new_from_file(icon))
        self._setup_layout()
        
    def _setup_layout(self):
        self.password_entry = Entry()
        self.password_entry.set_visibility(False)
        self.password_entry.set_invisible_char('*')
        info_label = Label(' Enter root password ')
        
        self.hbox = HBox()
                
        self.vbox.pack_start(info_label)
        self.vbox.pack_start(self.password_entry)
        self.vbox.pack_start(self.hbox)        
        self.show_all()
        
    def show_warning(self):
        image = Image()
        image.set_from_stock(STOCK_STOP, ICON_SIZE_BUTTON)
        warning_label = Label(' Invalid Password! ')        
        self.hbox.pack_start(image, False, False, 10)
        self.hbox.pack_start(warning_label, False, False, 0)
        self.show_all()
コード例 #4
0
ファイル: HourEntry.py プロジェクト: rbemmanuel/openlanhouse
 def __init__(self):
     HBox.__init__(self)
     self.set_spacing(3)
     
     #hour spin
     self.__hour_spin = SpinButton()
     self.__hour_spin.set_range(00, 99)
     self.__hour_spin.set_width_chars(2)
     self.__hour_spin.set_increments(1, 1)
     self.__hour_spin.set_numeric(True)
     self.__hour_spin.set_update_policy(UPDATE_IF_VALID)
     self.__hour_spin.set_snap_to_ticks(True)
     self.__hour_spin.connect("output", self._on_spin_output)
     self.__hour_spin_handler = (self.__hour_spin.connect("value-changed",
                               self.hour_spin_changed))
     self.pack_start(self.__hour_spin)
     self.__hour_spin.show()
     
     #separator
     sep = Label(":")
     self.pack_start(sep, expand=False)
     sep.show()
     
     #minute spin
     self.__minute_spin = SpinButton()
     self.__minute_spin.set_range(00, 59)
     self.__minute_spin.set_width_chars(2)
     self.__minute_spin.set_increments(1, 1)
     self.__minute_spin.set_numeric(True)
     self.__minute_spin.set_wrap(True)
     self.__minute_spin.set_update_policy(UPDATE_IF_VALID)
     self.__minute_spin.set_snap_to_ticks(True)
     self.__minute_spin.connect("output", self._on_spin_output)
     self.__minute_spin.connect("wrapped", self._on_minute_wrap)
     self.__minute_spin_handler = (self.__minute_spin.connect("value-changed",
                               self.minute_spin_changed))
     self.pack_start(self.__minute_spin)
     self.__minute_spin.show()
     
     #separator
     self.__second_sep = Label(":")
     self.pack_start(self.__second_sep, expand=False)
     self.__second_sep.show()
     
     #seconds spin
     self.__second_spin = SpinButton()
     self.__second_spin.set_range(00, 59)
     self.__second_spin.set_width_chars(2)
     self.__second_spin.set_increments(1, 1)
     self.__second_spin.set_numeric(True)
     self.__second_spin.set_wrap(True)
     self.__second_spin.set_update_policy(UPDATE_IF_VALID)
     self.__second_spin.set_snap_to_ticks(True)
     self.__second_spin.connect("output", self._on_spin_output)
     self.__second_spin.connect("wrapped", self._on_second_wrap)
     self.__second_spin_handler = (self.__second_spin.connect("value-changed",
                                   self.second_spin_changed))
     self.pack_start(self.__second_spin)
     self.__second_spin.show()
コード例 #5
0
    def __init__(self):
        HBox.__init__(self)
        self.set_spacing(3)

        #hour spin
        self.__hour_spin = SpinButton()
        self.__hour_spin.set_range(00, 99)
        self.__hour_spin.set_width_chars(2)
        self.__hour_spin.set_increments(1, 1)
        self.__hour_spin.set_numeric(True)
        self.__hour_spin.set_update_policy(UPDATE_IF_VALID)
        self.__hour_spin.set_snap_to_ticks(True)
        self.__hour_spin.connect("output", self._on_spin_output)
        self.__hour_spin_handler = (self.__hour_spin.connect(
            "value-changed", self.hour_spin_changed))
        self.pack_start(self.__hour_spin)
        self.__hour_spin.show()

        #separator
        sep = Label(":")
        self.pack_start(sep, expand=False)
        sep.show()

        #minute spin
        self.__minute_spin = SpinButton()
        self.__minute_spin.set_range(00, 59)
        self.__minute_spin.set_width_chars(2)
        self.__minute_spin.set_increments(1, 1)
        self.__minute_spin.set_numeric(True)
        self.__minute_spin.set_wrap(True)
        self.__minute_spin.set_update_policy(UPDATE_IF_VALID)
        self.__minute_spin.set_snap_to_ticks(True)
        self.__minute_spin.connect("output", self._on_spin_output)
        self.__minute_spin.connect("wrapped", self._on_minute_wrap)
        self.__minute_spin_handler = (self.__minute_spin.connect(
            "value-changed", self.minute_spin_changed))
        self.pack_start(self.__minute_spin)
        self.__minute_spin.show()

        #separator
        self.__second_sep = Label(":")
        self.pack_start(self.__second_sep, expand=False)
        self.__second_sep.show()

        #seconds spin
        self.__second_spin = SpinButton()
        self.__second_spin.set_range(00, 59)
        self.__second_spin.set_width_chars(2)
        self.__second_spin.set_increments(1, 1)
        self.__second_spin.set_numeric(True)
        self.__second_spin.set_wrap(True)
        self.__second_spin.set_update_policy(UPDATE_IF_VALID)
        self.__second_spin.set_snap_to_ticks(True)
        self.__second_spin.connect("output", self._on_spin_output)
        self.__second_spin.connect("wrapped", self._on_second_wrap)
        self.__second_spin_handler = (self.__second_spin.connect(
            "value-changed", self.second_spin_changed))
        self.pack_start(self.__second_spin)
        self.__second_spin.show()
コード例 #6
0
ファイル: Utils.py プロジェクト: mystilleef/scribes
def create_encoding_box(combobox):
	from i18n import msg0157
	from gtk import Label, HBox
	label = Label(msg0157)
	label.set_use_underline(True)
	hbox = HBox(homogeneous=False, spacing=10)
	hbox.pack_start(label, False, False, 0)
	hbox.pack_start(combobox, True, True, 0)
	return hbox
コード例 #7
0
 def __init__(self, item, name='ItemLabel'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.vlabel = Label(self._val_)
     self.pack_start(self.label, 0, 0, 0)
     self.pack_end(self.vlabel, 0, 0, 0)
     map(lambda x: x.show(), [self.label, self.vlabel])
     self.show()
コード例 #8
0
 def __init__(self, item, name='ItemButton'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.button = Button(label=self._val_)
     self.pack_start(self.label, 0, 0, 0)
     self.pack_end(self.button, 1, 1, 5)
     map(lambda x: x.show(), [self.label, self.button])
     self.show()
コード例 #9
0
ファイル: differ.py プロジェクト: pombredanne/paella-svn
 def __init__(self, name='UDBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.ubutton = Button('update')
     self.dbutton = Button('diff')
     self.pack_start(self.ubutton, 0, 0, 0)
     self.pack_end(self.dbutton, 0, 0, 0)
     self.ubutton.show()
     self.dbutton.show()
     self.show()
コード例 #10
0
 def __init__(self, item, name='ItemLabel'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.vlabel = Label(self._val_)
     self.pack_start(self.label,0,0,0)
     self.pack_end(self.vlabel,0,0,0)
     map(lambda x: x.show(), [self.label, self.vlabel])
     self.show()        
コード例 #11
0
ファイル: differ.py プロジェクト: BackupTheBerlios/paella-svn
 def __init__(self, name='UDBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.ubutton = Button('update')
     self.dbutton = Button('diff')
     self.pack_start(self.ubutton, 0, 0, 0)
     self.pack_end(self.dbutton, 0, 0, 0)
     self.ubutton.show()
     self.dbutton.show()
     self.show()
コード例 #12
0
 def __init__(self, item, name='ItemButton'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.button = Button(label=self._val_)
     self.pack_start(self.label,0,0,0)
     self.pack_end(self.button,1,1,5)
     map(lambda x: x.show(), [self.label, self.button])
     self.show()
コード例 #13
0
 def __init__(self, item, name='ItemEntry'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.entry = Entry()
     self.entry.set_text(self._val_)
     self.pack_start(self.label, 0, 0, 0)
     self.pack_end(self.entry, 0, 0, 0)
     map(lambda x: x.show(), [self.label, self.entry])
     self.show()
コード例 #14
0
 def __init__(self, item, name='ItemEntry'):
     HBox.__init__(self)
     self.set_name(name)
     self._key_, self._val_ = item
     self.label = Label(self._key_)
     self.entry = Entry()
     self.entry.set_text(self._val_)
     self.pack_start(self.label,0,0,0)
     self.pack_end(self.entry,0,0,0)
     map(lambda x: x.show(), [self.label, self.entry])
     self.show()
コード例 #15
0
 def __init_attributes(self, manager, editor):
     self.__manager = manager
     self.__editor = editor
     self.__label = self.__get_label()
     self.__button = self.__get_button()
     self.__bar = self.__get_bar()
     from gtk import HBox, Image
     self.__box = HBox(False, 5)
     self.__image = Image()
     self.__view = editor.textview
     return
コード例 #16
0
ファイル: middle.py プロジェクト: pombredanne/paella-svn
 def __init__(self, name, default=None):
     HBox.__init__(self)
     self.set_name(name)
     self.label = Label(name)
     self.entry = Entry()
     self.pack_start(self.label, TRUE, TRUE, 0)
     self.add(self.entry)
     self.label.show()
     self.entry.show()
     if default:
         self.set(default)
     self.show()
コード例 #17
0
 def __init__(self, message, name='MyScrollBox', type='v'):
     Dialog.__init__(self, message, name=name)
     self.scroll = ScrolledWindow()
     self.scroll.show()
     self.vbox.pack_start(self.scroll, TRUE, TRUE, 0)
     self.set_size_request(150, 300)
     if type =='v':
         self.mbox = VBox()
     else:
         self.mbox = HBox()
     self.scroll.add_with_viewport(self.mbox)
     self.mbox.show()
コード例 #18
0
 def __init__(self):
     HBox.__init__(self)
     MDSplusWidget.__init__(self)
     HBox.set_homogeneous(self, False)
     self.node_state = CheckButton('')
     self.button = Button()
     HBox.pack_start(self, self.node_state, False, False, 0)
     HBox.pack_start(self, self.button, False, False, 0)
     HBox.pack_start(self, Label(''), True, False, 0)
     if not guibuilder:
         self.button.connect("clicked", self.popupXd)
     self.button.connect("realize", self.setButtonLabel)
コード例 #19
0
ファイル: utils.py プロジェクト: pombredanne/paella-svn
 def __init__(self, queue):
     HBox.__init__(self)
     self.thread = DlWorker(queue, self.progress, self.set_url)
     self.label = Label('hello')
     self.pbar = ProgressBar()
     self.pack_start(self.label, FALSE, FALSE, 0)
     self.pack_end(self.pbar, FALSE, FALSE, 0)
     self.label.show()
     self.pbar.show()
     self.show()
     self._done = False
     self._started = False
コード例 #20
0
ファイル: utils.py プロジェクト: BackupTheBerlios/useless-svn
 def __init__(self, queue):
     HBox.__init__(self)
     self.thread = DlWorker(queue, self.progress, self.set_url)
     self.label = Label("hello")
     self.pbar = ProgressBar()
     self.pack_start(self.label, FALSE, FALSE, 0)
     self.pack_end(self.pbar, FALSE, FALSE, 0)
     self.label.show()
     self.pbar.show()
     self.show()
     self._done = False
     self._started = False
コード例 #21
0
 def __init__(self):
     HBox.__init__(self)
     MDSplusWidget.__init__(self)
     HBox.set_homogeneous(self,False)
     self.node_state=CheckButton('')
     self.button=Button()
     HBox.pack_start(self,self.node_state,False,False,0)
     HBox.pack_start(self,self.button,False,False,0)
     HBox.pack_start(self,Label(''),True,False,0)
     if not guibuilder:
         self.button.connect("clicked",self.popupXd)
     self.button.connect("realize",self.setButtonLabel)
コード例 #22
0
ファイル: dialogs.py プロジェクト: pombredanne/paella-svn
 def __init__(self, message, name='MyScrollBox', type='v'):
     Dialog.__init__(self, message, name=name)
     self.scroll = ScrolledWindow()
     self.scroll.show()
     self.vbox.pack_start(self.scroll, TRUE, TRUE, 0)
     self.set_size_request(150, 300)
     if type == 'v':
         self.mbox = VBox()
     else:
         self.mbox = HBox()
     self.scroll.add_with_viewport(self.mbox)
     self.mbox.show()
コード例 #23
0
 def __init__(self, name, default=None):
     HBox.__init__(self)
     self.set_name(name)
     self.label = Label(name)
     self.entry = Entry()
     self.pack_start(self.label, True, True, 0)
     self.add(self.entry)
     self.label.show()
     self.entry.show()
     if default:
         self.set(default)
     self.show()
コード例 #24
0
ファイル: differ.py プロジェクト: BackupTheBerlios/paella-svn
 def __init__(self, name='TraitBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.lcombo = MyCombo()
     self.rcombo = MyCombo()
     self.lcombo.set('')
     self.rcombo.set('')
     self.cbutton = Button('clear')
     self.cbutton.show()
     self.pack_start(self.lcombo, 0, 0, 0)
     self.pack_end(self.rcombo, 0, 0, 0)
     self.add(self.cbutton)
     self.show()
コード例 #25
0
ファイル: differ.py プロジェクト: pombredanne/paella-svn
 def __init__(self, name='TraitBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.lcombo = MyCombo()
     self.rcombo = MyCombo()
     self.lcombo.set('')
     self.rcombo.set('')
     self.cbutton = Button('clear')
     self.cbutton.show()
     self.pack_start(self.lcombo, 0, 0, 0)
     self.pack_end(self.rcombo, 0, 0, 0)
     self.add(self.cbutton)
     self.show()
コード例 #26
0
 def __init__(self, item, name='ItemEntry'):
     if len(item) != 2:
         raise Error, 'ItemEntry needs item not %s' %item
     field, value = item
     HBox.__init__(self)
     self.set_name(name)
     self.label = Label(field)
     self.pack_start(self.label, FALSE, FALSE, 0)
     self.entry = Entry()
     self.set(str(value))
     self.pack_end(self.entry, TRUE, TRUE, 0)
     self.label.show()
     self.entry.show()
     self.show()
コード例 #27
0
 def __init__(self, item, name='ItemEntry'):
     if len(item) != 2:
         raise Error, 'ItemEntry needs item not %s' % item
     field, value = item
     HBox.__init__(self)
     self.set_name(name)
     self.label = Label(field)
     self.pack_start(self.label, FALSE, FALSE, 0)
     self.entry = Entry()
     self.set(str(value))
     self.pack_end(self.entry, TRUE, TRUE, 0)
     self.label.show()
     self.entry.show()
     self.show()
コード例 #28
0
ファイル: Utils.py プロジェクト: mystilleef/scribes
def create_button(stock_id, string):
	from gtk import HBox, Image, Label, ICON_SIZE_BUTTON, Alignment
	alignment = Alignment()
	alignment.set_property("xalign", 0.5)
	alignment.set_property("yalign", 0.5)
	hbox = HBox(False, 3)
	if stock_id:
		image = Image()
		image.set_from_stock(stock_id, ICON_SIZE_BUTTON)
		hbox.pack_start(image, False, False, 0)
	label = Label(string)
	label.set_property("use-underline", True)
	hbox.pack_start(label, False, False, 0)
	alignment.add(hbox)
	return alignment
コード例 #29
0
ファイル: differ.py プロジェクト: BackupTheBerlios/paella-svn
 def __init__(self, suites, name='SuiteBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.lcombo = MyCombo(suites)
     self.lcombo.set(suites[0])
     self.rcombo = MyCombo(suites)
     self.rcombo.set(suites[0])
     self.ubutton = Button('update')
     self.dbutton = Button('diff')
     self.pack_start(self.lcombo, 0, 0, 0)
     self.pack_end(self.rcombo, 0, 0, 0)
     self.add(self.ubutton)
     self.add(self.dbutton)
     self.ubutton.show()
     self.dbutton.show()
     self.show()
コード例 #30
0
ファイル: differ.py プロジェクト: pombredanne/paella-svn
 def __init__(self, suites, name='SuiteBar'):
     HBox.__init__(self)
     self.set_name(name)
     self.lcombo = MyCombo(suites)
     self.lcombo.set(suites[0])
     self.rcombo = MyCombo(suites)
     self.rcombo.set(suites[0])
     self.ubutton = Button('update')
     self.dbutton = Button('diff')
     self.pack_start(self.lcombo, 0, 0, 0)
     self.pack_end(self.rcombo, 0, 0, 0)
     self.add(self.ubutton)
     self.add(self.dbutton)
     self.ubutton.show()
     self.dbutton.show()
     self.show()
コード例 #31
0
    def __init__(self, dir=None):
        HBox.__init__(self, False, 2)

        buttonImage = Image()
        buttonImage.set_from_stock(STOCK_REFRESH, ICON_SIZE_MENU)

        self.combo = ComboBox()
        self.refreshButton = Button()
        self.refreshButton.set_image(buttonImage)
        self.refreshButton.connect('clicked', self.refreshButton_clicked, None)
        self.model = ListStore(str)
        self.combo.set_model(self.model)
        self.dir = dir

        self.pack_start(self.combo, False, False, 0)
        self.pack_start(self.refreshButton, False, False, 0)

        if self.dir != None and exists(self.dir):
            self.refresh()
コード例 #32
0
ファイル: Widget.py プロジェクト: mystilleef/scribes
	def __init_attributes(self, manager, editor):
		self.__manager = manager
		self.__editor = editor
		self.__label = self.__get_label()
		self.__button = self.__get_button()
		self.__bar = self.__get_bar()
		from gtk import HBox, Image
		self.__box = HBox(False, 5)
		self.__image = Image()
		self.__view = editor.textview
		return
コード例 #33
0
	def quiz(self, widget=None):
		"""Quiz the user on a random subset of the playlist."""
		subset = sample(self.playlist, self.num_songs)
		clipStarts = [randrange(0, int(_length(i)) - _clip_length, 1)
			for i in subset]
		log.debug("Clip starts: %s" % clipStarts)
		self.answers = [{'artist': _artist(i), 'title': _title(i),
			'genre': _genre(i), 'year': _year(i)} for i in subset]
		artist_pool = set(_artist(i) for i in subset)
		title_pool = set(_title(i) for i in subset)
		date_pool = set(_year(i) for i in subset)
		genre_pool = set(_genre(i) for i in subset)
		self.responses = []

		# Set up quiz_vbox. Remove old children if they're lying around.
		for child in self.quiz_vbox.get_children():
			self.quiz_vbox.remove(child)
		for i in xrange(self.num_songs):
			widget = HBox();
			artist_cb = combo_box_new_text()
			for artist in artist_pool:
				artist_cb.append_text(artist)
			title_cb = combo_box_new_text()
			for title in title_pool:
				title_cb.append_text(title)
			date_cb = combo_box_new_text()
			for date in date_pool:
				date_cb.append_text(date)
			genre_cb = combo_box_new_text()
			for genre in genre_pool:
				genre_cb.append_text(genre)
			widget.pack_start(artist_cb)
			widget.pack_start(title_cb)
			widget.pack_start(date_cb)
			widget.pack_start(genre_cb)
			self.quiz_vbox.pack_start(widget)

		self.quiz_vbox.show_all()
		self.notebook.next_page()
		# Look into doing follow-up code (running the quiz) with a callback
		# registered to the notebook's "switch-page" signal.

		# Prepare quiz to run in a separate thread.
		self.thread = Thread(target=self.play_subset,
						kwargs={'subset':subset, 'clipStarts':clipStarts})
		self.thread.start()
コード例 #34
0
 def _setup_layout(self):
     self.password_entry = Entry()
     self.password_entry.set_visibility(False)
     self.password_entry.set_invisible_char('*')
     info_label = Label(' Enter root password ')
     
     self.hbox = HBox()
             
     self.vbox.pack_start(info_label)
     self.vbox.pack_start(self.password_entry)
     self.vbox.pack_start(self.hbox)        
     self.show_all()
コード例 #35
0
ファイル: windows.py プロジェクト: pombredanne/paella-svn
    def __init__(self):
        Window.__init__(self)
        self.vbox = VBox()
        self.button_box = HBox()
        self.listbox = TwinCList()

        self.vbox.add(self.listbox)
        self.add(self.vbox)
        self.vbox.show()
        self.show()
        self.set_size_request(300, 200)
        self.listbox.set_position(140)
コード例 #36
0
 def dtype_menu(self, itemlist, varname='dtype', no_show=False):
     menu = combo_box_new_text()
     for item in itemlist:
         menu.append_text(item)
     menu.append_text("Expression")
     menu.append_text("Undefined")
     menu.set_active(len(itemlist) + 1)
     menu.connect('changed', self.dtype_changed)
     exec('self.%s=menu' % (varname, ))
     ans = HBox(homogeneous=False)
     exec('ans.pack_start(self.%s,False,False,0)' % (varname, ))
     if no_show:
         menu.set_no_show_all(True)
     return ans
コード例 #37
0
ファイル: Utils.py プロジェクト: mystilleef/scribes
def create_menuitem(string, stock_id=None):
	from gtk import MenuItem, Image, HBox, Label
	hbox = HBox(spacing=7)
	hbox.set_property("border-width", 2)
	if stock_id:
		image = Image()
		image.set_property("stock", stock_id)
		hbox.pack_start(image, False, False, 0)
	label = Label(string)
	label.set_property("use-underline", True)
	hbox.pack_start(label, False, False, 0)
	menuitem = MenuItem()
	menuitem.add(hbox)
	return menuitem
コード例 #38
0
 def initXdbox(self):
     self.xdbox = Window()
     try:
         self.xdbox.set_title(str(self.node))
     except:
         pass
     vbox = VBox()
     self.xdbox.expr = MDSplusExprWidget()
     vbox.pack_start(self.xdbox.expr, True, True, 20)
     close = Button(stock=STOCK_CLOSE)
     close.connect("clicked", self.xdbox_close)
     redo = Button(stock=STOCK_REDO)
     redo.connect("clicked", self.xdbox_redo)
     cancel = Button(stock=STOCK_CANCEL)
     cancel.connect("clicked", self.xdbox_cancel)
     hbox = HBox()
     hbox.pack_start(close, False, False, 20)
     hbox.pack_start(redo, False, False, 20)
     hbox.pack_start(cancel, False, False, 20)
     vbox.pack_start(hbox, False, False, 20)
     self.xdbox.add(vbox)
     self.xdbox.expr.set_text(self.node_value())
コード例 #39
0
 def initXdbox(self):
     self.xdbox=Window()
     try:
         self.xdbox.set_title(str(self.node))
     except:
         pass
     vbox=VBox()
     self.xdbox.expr=MDSplusExprWidget()
     vbox.pack_start(self.xdbox.expr,True,True,20)
     close=Button(stock=STOCK_CLOSE)
     close.connect("clicked",self.xdbox_close)
     redo=Button(stock=STOCK_REDO)
     redo.connect("clicked",self.xdbox_redo)
     cancel=Button(stock=STOCK_CANCEL)
     cancel.connect("clicked",self.xdbox_cancel)
     hbox=HBox()
     hbox.pack_start(close,False,False,20)
     hbox.pack_start(redo,False,False,20)
     hbox.pack_start(cancel,False,False,20)
     vbox.pack_start(hbox,False,False,20)
     self.xdbox.add(vbox)
     self.xdbox.expr.set_text(self.node_value())
コード例 #40
0
ファイル: MainWindow.py プロジェクト: fredmorcos/attic
	def __init__ (self, title):
		Window.__init__(self)
		self.set_title(title)
		self.set_border_width(5)
		self.set_app_paintable(True)

		calendar = Calendar()
		testItem1 = SimpleItem('Hello')
		testItem2 = SimpleItem('This is Cool', '#b81919', '8f1b1b')

		toolBox = VBox(False, 5)
		toolBox.pack_start(testItem1, False, False, 0)
		toolBox.pack_start(testItem2, False, False, 0)

		mainBox = HBox(False, 5)
		mainBox.pack_start(toolBox, False, False, 0)
		mainBox.pack_start(calendar, False, False, 0)

		self.add(mainBox)
		self.maximize()

		self.connect('expose-event', self.expose, None)
		self.connect('destroy', main_quit)
コード例 #41
0
    def __init__(self, objectives, new):
        Expander.__init__(self)

        self.connect("enter-notify-event", self.onEnterNotifyEvent)
        self.connect("leave-notify-event", self.onLeaveNotifyEvent)

        vBox = VBox()
        self.add(vBox)

        # Data model
        self.model = ListStore(str, float)

        # Title bar
        hBox = HBox()
        self.set_property("label-widget", hBox)

        self.title = Label()
        hBox.pack_start(self.title)

        # Alternatives
        treeView = TreeView(self.model)
        #		treeView.set_headers_visible(False)
        vBox.pack_start(treeView)

        listStore_objectives = ListStore(str)
        for name in objectives:
            listStore_objectives.append((name, ))

        def combo_changed(_, path, text, model):
            model[path][0] = text

        cellRenderer = CellRendererCombo()
        cellRenderer.connect("edited", combo_changed, self.model)
        cellRenderer.set_property("text-column", 0)
        cellRenderer.set_property("editable", True)
        cellRenderer.set_property("has-entry", True)
        cellRenderer.set_property("model", listStore_objectives)

        treeViewColumn = TreeViewColumn("Alternative", cellRenderer, text=0)
        #		treeViewColumn = TreeViewColumn(None,cellRenderer,text=0)
        treeView.append_column(treeViewColumn)

        def spin_changed(_, path, value, model):
            model[path][1] = float(value.replace(",", "."))

        cellRenderer = CellRendererSpin()
        cellRenderer.connect("edited", spin_changed, self.model)
        cellRenderer.set_property("adjustment",
                                  Adjustment(1, 0, 100, 1, 10, 0))
        cellRenderer.set_property("editable", True)
        cellRenderer.set_property("digits", 2)

        treeViewColumn = TreeViewColumn(None, cellRenderer, text=1)
        treeView.append_column(treeViewColumn)

        # Add/remove alternative button box
        #		hButtonBox = HButtonBox()
        #		vBox.pack_start(hButtonBox, False)

        # Add alternative
        button = Button("gtk-add")
        button.connect("clicked", self.on_btnAdd_Alternative_clicked)
        button.set_use_stock(True)
        #		hButtonBox.pack_start(button)
        vBox.pack_start(button, False)

        #		# Remove alternative
        #		button = Button("gtk-remove")
        #		button.connect("clicked",self.on_btnDel_Alternative_clicked)
        #		button.set_use_stock(True)
        #		hButtonBox.pack_start(button)

        # Expand the requeriment and add an alternative if it's new
        if new:
            self.set_expanded(True)
            self.model.append((None, 1.0))

        # Show requeriment
        self.show_all()

        # Delete requeriment button (default is hidden)
        self.imgRemove = Image()
        self.imgRemove.connect("button-press-event", self.onDelRequeriment)
        self.imgRemove.set_from_stock("gtk-cancel", ICON_SIZE_MENU)
        hBox.pack_start(self.imgRemove)
コード例 #42
0
ファイル: mdsplusxdbox.py プロジェクト: LucyScott/mdsplus
 def __init__(self, node=None, value=None):
     Window.__init__(self)
     MDSplusWidget.__init__(self)
     if node is not None:
         self.node = node
     else:
         self.value = value
     hbtop = HBox(homogeneous=False)
     self.on = CheckButton(label="On")
     self.parent_on = CheckButton(label="Parent")
     self.parent_on.set_sensitive(False)
     self.path = MDSplusPathWidget()
     if node is not None:
         self.path._node = self._node
     hbtags = HBox(homogeneous=False)
     self.tags = Entry()
     self.tags.set_width_chars(60)
     expression_menu = self.dtype_menu(tuple(), varname="dtype_expression", no_show=True)
     axis_menu = self.dtype_menu(("Range",), varname="dtype_axis", no_show=True)
     window_menu = self.dtype_menu(("Window",), varname="dtype_window", no_show=True)
     dispatch_menu = self.dtype_menu(("Dispatch",), varname="dtype_dispatch", no_show=True)
     action_menu = self.dtype_menu(("Action",), varname="dtype_action", no_show=True)
     task_menu = self.dtype_menu(("Method", "Routine"), varname="dtype_task", no_show=True)
     any_menu = self.dtype_menu(
         ("Range", "Window", "Dispatch", "Action", "Method", "Routine"), varname="dtype_any", no_show=True
     )
     menus = (
         self.dtype_expression,
         self.dtype_axis,
         self.dtype_dispatch,
         self.dtype_action,
         self.dtype_task,
         self.dtype_window,
         self.dtype_any,
     )
     hbtop.pack_start(self.on, False, False, 10)
     hbtop.pack_start(self.parent_on, False, False, 10)
     hbtop.pack_start(self.path, False, False, 0)
     hbtags.pack_start(Label("Tags:"), False, False, 10)
     hbtags.pack_start(self.tags, False, False, 0)
     self.action = MDSplusActionWidget()
     self.windoww = MDSplusWindowWidget()
     self.sequential = MDSplusSequentialWidget()
     self.expression = MDSplusExpressionWidget()
     self.method = MDSplusMethodWidget()
     self.routine = MDSplusRoutineWidget()
     self.dispatch = MDSplusDispatchWidget()
     self.range = MDSplusRangeWidget()
     self.widgets = (
         self.action,
         self.sequential,
         self.expression,
         self.method,
         self.routine,
         self.dispatch,
         self.range,
         self.windoww,
     )
     self.ok = Button(stock=STOCK_OK)
     self.cancel = Button(stock=STOCK_CANCEL)
     self.redo = Button(stock=STOCK_REDO)
     self.ok.connect("clicked", self.do_ok)
     self.cancel.connect("clicked", self.do_cancel)
     self.redo.connect("clicked", self.do_redo)
     hb2 = HBox()
     hb2.add(self.ok)
     hb2.add(self.redo)
     hb2.add(self.cancel)
     vb = VBox(homogeneous=False)
     vb.set_border_width(10)
     vb.pack_start(hbtop, False, False, 0)
     vb.pack_start(hbtags, False, False, 0)
     vb.pack_start(expression_menu, False, False, 0)
     vb.pack_start(axis_menu, False, False, 0)
     vb.pack_start(window_menu, False, False, 0)
     vb.pack_start(dispatch_menu, False, False, 0)
     vb.pack_start(action_menu, False, False, 0)
     vb.pack_start(task_menu, False, False, 0)
     vb.pack_start(any_menu, False, False, 0)
     for w in self.widgets:
         w.set_no_show_all(True)
         vb.pack_start(w, False, False, 0)
     vb.pack_start(hb2, False, False, 20)
     self.add(vb)
     self.do_redo(self.redo)
     self.putOnApply = True
     self.nidOffset = -1
コード例 #43
0
ファイル: mdsplusxdbox.py プロジェクト: LucyScott/mdsplus
 def inHBox(self, w):
     hb = HBox()
     hb.pack_start(w, False, False, 0)
     return hb
コード例 #44
0
ファイル: startslideshow.py プロジェクト: pborky/pyslides
class Base(object):
    def __init__(self):
        from gtk import Window,WINDOW_TOPLEVEL,Button,Label,HBox,Entry,VBox,VSeparator
        self.window =  Window(WINDOW_TOPLEVEL)
        self.window.set_title("Slideshow")
        self.window.connect("delete_event", self.delete_event)
        self.window.set_border_width(10)
        self.vbox = VBox(False, 0)
        self.window.add(self.vbox)
        self.hbox1 = HBox(False, 0)
        self.vbox.pack_start(self.hbox1, True, True, 1)
        self.hbox = HBox(False, 0)
        self.vbox.pack_start(self.hbox, False, False, 1)
        self.hbox2 = HBox(False, 0)
        self.vbox.pack_start(self.hbox2, True, True, 1)
        self.label = Label('Identifikační číslo:')
        self.hbox.pack_start(self.label, False, False, 1)
        self.label.show()
        self.editable = Entry()
        self.editable.connect('key_press_event', self.key_press_event)
        self.hbox.pack_start(self.editable, True, True, 1)
        self.editable.show()
        self.button = Button("Začít")
        self.button.connect("clicked", self.callback)
        self.button.set_receives_default(True)
        self.button.set_can_focus(True)
        self.hbox.pack_start(self.button, False, False, 1)
        self.button.show()
        self.hbox1.show()
        self.hbox.show()
        self.hbox2.show()
        self.vbox.show()
        self.window.show()
    def delete_event(self, widget, event, data=None):
        gtk.main_quit()
        return False
    def key_press_event(self, widget, event):
        from gtk.gdk import keyval_from_name,keyval_name
        if event.keyval in (keyval_from_name('Return'),keyval_from_name('KP_Enter')):
            self.callback(widget)
    def _getFilePaths(self, fileTypes, recursive=True):
        import os
        import re
        from sys import argv
        pt = re.compile(r'.*([%(0)s][^%(0)s]*)'%{'0':os.path.extsep})
        path = [a for m,a in ((pt.match(os.path.basename(a)),a) for a in argv[1:]) if m and m.group(1) in fileTypes]
        if not path:
            path = '/home/pi/img/*.jpg'
        if isinstance(path, str):
            ## Returns list containing paths of files in /path/ that are of a file type in /fileTypes/,
            ##	if /recursive/ is False subdirectories are not checked.
            paths = []
            if recursive:
                for root, folders, files in os.walk(path, followlinks=True):
                    for file in files:
                        for fileType in fileTypes:
                            if file.endswith(fileType):
                                paths.append(os.path.join(root, file))
            else:
                for item in os.listdir(path):
                    for fileType in fileTypes:
                        if item.endswith(fileType):
                            paths.append(os.path.join(root, item))
            return paths
        elif iterable(path):
            return path
        else:
            return []
    def _init_cb(self,trans):
        from threading import Thread
        if not iterable(trans):
            trans = trans,
        callbacks  = []
        for name,cb in trans:
            t = Thread(target=cb, name='%sThread'%name)
            t.daemon = True
            t.start()
            callbacks.append(cb.enqueue)
        def wrap(msg):
            for cb in callbacks:
                if not cb(msg):
                    return False
            return True
        return wrap
    def callback(self, widget):
        from slideshow import SlideShow
        from trans import Message,GpioTransceiver,JsonTransceiver

        if not self.editable.get_text():
            return False
        img_cbs = self._init_cb([('ImgGpioCallback',GpioTransceiver(24)),('ImgJsonCallback',JsonTransceiver('img.json'))])
        kp_cbs = self._init_cb([('KpGpioCallback',GpioTransceiver(26,bcd=False)),('KpJsonCallback',JsonTransceiver('kp.json'))])
        def ordfnc(path):
            from numpy.random import permutation
            gray = path[0]
            result = []
            for p in permutation(path[1:]):
                result.append(p)
                result.append(gray)
            return result
        slide = SlideShow(
            path=self._getFilePaths(('.jpg', '.jpeg', '.png')),
            transition='None',
            fullscreen=True,
            delay=5,
            order=ordfnc,
            principal=self.editable.get_text(),
            img_callback = img_cbs,
            kp_callback = kp_cbs,
        )
        self.editable.set_text('')
        slide()
    def __call__(self):
        gtk.main()
コード例 #45
0
ファイル: Widget.py プロジェクト: mystilleef/scribes
class Widget(SignalManager):

	def __init__(self, manager, editor):
		SignalManager.__init__(self)
		self.__init_attributes(manager, editor)
		self.__setup()
		self.__emit()
		self.__update_public_api()
		self.connect(editor, "quit", self.__quit_cb)
		editor.register_object(self)
		self.__bar.hide()

	def __init_attributes(self, manager, editor):
		self.__manager = manager
		self.__editor = editor
		self.__label = self.__get_label()
		self.__button = self.__get_button()
		self.__bar = self.__get_bar()
		from gtk import HBox, Image
		self.__box = HBox(False, 5)
		self.__image = Image()
		self.__view = editor.textview
		return

	def __destroy(self):
		self.disconnect()
		self.__editor.unregister_object(self)
		del self
		return False

	def __setup(self):
		from gtk import TEXT_WINDOW_WIDGET
		self.__view.add_child_in_window(self.__bar, TEXT_WINDOW_WIDGET, 0, -100)
		self.__bar.add(self.__button)
		self.__button.add(self.__box)
		self.__box.pack_start(self.__image, False, False)
		self.__box.pack_start(self.__label, False, False)
		self.__bar.realize()
		self.__bar.hide()
		return False

	def __emit(self):
		self.__manager.emit("bar", self.__bar)
		return False

	def __update_public_api(self):
		self.__editor.set_data("MessageBar", self.__manager)
		self.__editor.set_data("StatusImage", self.__image)
		self.__editor.set_data("StatusFeedback", self.__label)
		return False

	def __get_bar(self):
		from gtk import EventBox
		bar = EventBox()
#		bar.props.visible_window = False
		return bar

	def __get_label(self):
		from gtk import Label
		label = Label()
		label.set_property("single-line-mode", True)
		label.set_property("use-markup", True)
		return label

	def __get_button(self):
		from gtk import Button
		button = Button()
		button.set_property("focus-on-click", False)
		button.set_property("can-default", False)
		button.set_property("can-focus", False)
		button.set_property("has-default", False)
		button.set_property("is-focus", False)
		button.set_property("receives-default", False)
		button.set_property("receives-default", False)
		return button

	def __quit_cb(self, *args):
		self.__destroy()
		return False
コード例 #46
0
class Widget(SignalManager):
    def __init__(self, manager, editor):
        SignalManager.__init__(self)
        self.__init_attributes(manager, editor)
        self.__setup()
        self.__emit()
        self.__update_public_api()
        self.connect(editor, "quit", self.__quit_cb)
        editor.register_object(self)
        self.__bar.hide()

    def __init_attributes(self, manager, editor):
        self.__manager = manager
        self.__editor = editor
        self.__label = self.__get_label()
        self.__button = self.__get_button()
        self.__bar = self.__get_bar()
        from gtk import HBox, Image
        self.__box = HBox(False, 5)
        self.__image = Image()
        self.__view = editor.textview
        return

    def __destroy(self):
        self.disconnect()
        self.__editor.unregister_object(self)
        del self
        return False

    def __setup(self):
        from gtk import TEXT_WINDOW_WIDGET
        self.__view.add_child_in_window(self.__bar, TEXT_WINDOW_WIDGET, 0,
                                        -100)
        self.__bar.add(self.__button)
        self.__button.add(self.__box)
        self.__box.pack_start(self.__image, False, False)
        self.__box.pack_start(self.__label, False, False)
        self.__bar.realize()
        self.__bar.hide()
        return False

    def __emit(self):
        self.__manager.emit("bar", self.__bar)
        return False

    def __update_public_api(self):
        self.__editor.set_data("MessageBar", self.__manager)
        self.__editor.set_data("StatusImage", self.__image)
        self.__editor.set_data("StatusFeedback", self.__label)
        return False

    def __get_bar(self):
        from gtk import EventBox
        bar = EventBox()
        #		bar.props.visible_window = False
        return bar

    def __get_label(self):
        from gtk import Label
        label = Label()
        label.set_property("single-line-mode", True)
        label.set_property("use-markup", True)
        return label

    def __get_button(self):
        from gtk import Button
        button = Button()
        button.set_property("focus-on-click", False)
        button.set_property("can-default", False)
        button.set_property("can-focus", False)
        button.set_property("has-default", False)
        button.set_property("is-focus", False)
        button.set_property("receives-default", False)
        button.set_property("receives-default", False)
        return button

    def __quit_cb(self, *args):
        self.__destroy()
        return False
コード例 #47
0
    def __init__(self,
                 trans, transid, plugin, gui_parent, change_register_function,
                 book, display_mode=TRANSACTION_ALL_EDIT_FIRST_TIME,
                 transaction_edit_finished_function=null_function):
        self.trans = trans
        self.transid = transid
        self.plugin = plugin
        self.gui_parent = gui_parent
        self.change_register_function = change_register_function
        self.book = book
        self.display_mode = display_mode
        self.transaction_edit_finished_function = (
            null_function if display_mode not in HEADLESS_MODES
            else transaction_edit_finished_function )

        self.hide_parent = Window()
        self.hide_parent.hide()
        self.mainvbox = VBox()
        self.hide_parent.add(self.mainvbox)

        config = self.trans.get_configuration_and_provide_on_load_hook()
        config_module_name = self.plugin.config_module_name
        if not config_valid(config):
            # even in the case of a broken config, we should still
            # display all of the data we have available...
            self.mainvbox.pack_start(Label("no configuration"))
        elif not self.trans.can_safely_proceed_with_config_module(config):
            # should display all data that's available instead of just
            # this label
            #
            # and should give
            # user an overide option where they either pick an old config
            # for one time use or just blow out the memory of having used
            # a different config...
            #
            # should also print the checksum itself so they know
            # what they need...
            #
            # perhaps eventually we even put in place some archival support
            # for saving old glade and config files and then code into the
            # the transaction -- hey, code you need to be editable is
            # over here..
            #
            # now hopefully there is no marking of this transaction dirty
            # in this mode and the extra safegaurds we put into
            # MultipageGladeTransaction don't get activated
            self.mainvbox.pack_start(
                Label("out of date configuration. data is read only here for "
                      "the safety of your old information, last adler "
                      "CRC was %s" % self.trans.config_crc_cache ))
        else:
            # if the safety cache was relied on before we need to tell the
            # backend that the transaction is actually dirty,
            # and now that we know that we have a workable config,
            # there's a chance that we'll actually be able to avoid
            # relying on the cache this time
            if self.trans.get_safety_cache_was_used():
                self.change_register_function()

            self.page_label = Label("")
            (x_align, y_align) = self.page_label.get_alignment()
            self.page_label.set_alignment(0.0, y_align)
            self.mainvbox.pack_start(self.page_label, expand=False)

            # establish maincontainer, which is where the actual glade
            # pages are put by attach_current_page
            #
            # The order of placement here is important, we place this
            # after page_label has already been added to main
            # and we also need to do this prior to attach_current_page
            # being called, as it depends on self.maincontainer being
            # there
            #
            # when we're in headless mode the maincontainer can just be
            # the mainvbox itself
            #
            # but, outside headless mode we save screen real-estate and
            # place a scrolled window (which becomes the maincontainer)
            # inside the mainvbox and the glade by glade pages end up
            # in there instead (again, in attach_current_page)
            if display_mode in HEADLESS_MODES:
                self.maincontainer = self.mainvbox
            else:
                self.maincontainer = Viewport()
                sw = ScrolledWindow()
                sw.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
                sw.add( self.maincontainer)
                self.mainvbox.pack_start(sw)

            self.glade_pages = [
                self.__setup_page(glade_file, top_glade_element)
                for glade_file, top_glade_element in config.pages ]
            self.glade_pages_by_ident_index = dict(
                ( (key, self.glade_pages[i])
                  for i, key in enumerate(config.pages)
                  ) # end generator expression
                ) # end dict
            
            self.__setup_auto_widgets()

            self.current_page = 0
            self.attach_current_page()

            button_hbox = HBox()
            self.mainvbox.pack_end(button_hbox, expand=False)
            self.nav_buts = dict( (Button(), i)
                                  for i in range(2) )
            for but, i in self.nav_buts.iteritems():
                but.set_property('use-stock', True)
                but.set_label( STOCK_GO_BACK
                               if i == GLADE_BACK_NAV else STOCK_GO_FORWARD )
                button_hbox.pack_start(but, expand=False)
                but.connect("clicked", self.nav_but_clicked)

            config.gui_initialization_hook(
                self, self.trans, self.plugin, self.book)

        self.mainvbox.show_all()
        self.mainvbox.reparent(self.gui_parent)
コード例 #48
0
 def inHBox(self,w):
     hb=HBox()
     hb.pack_start(w,False,False,0)
     return hb
コード例 #49
0
 def __init__(self,node=None,value=None):
     Window.__init__(self)
     MDSplusWidget.__init__(self)
     if node is not None:
         self.node=node
     else:
         self.value=value
     hbtop=HBox(homogeneous=False)
     self.on=CheckButton(label="On")
     self.parent_on=CheckButton(label="Parent")
     self.parent_on.set_sensitive(False)
     self.path=MDSplusPathWidget()
     if node is not None:
         self.path._node=self._node
     hbtags=HBox(homogeneous=False)
     self.tags=Entry()
     self.tags.set_width_chars(60)
     expression_menu=self.dtype_menu(tuple(),varname='dtype_expression',no_show=True)
     axis_menu=self.dtype_menu(('Range',),varname='dtype_axis',no_show=True)
     window_menu=self.dtype_menu(('Window',),varname='dtype_window',no_show=True)
     dispatch_menu=self.dtype_menu(('Dispatch',),varname='dtype_dispatch',no_show=True)
     action_menu=self.dtype_menu(('Action',),varname='dtype_action',no_show=True)
     task_menu=self.dtype_menu(('Method','Routine'),varname='dtype_task',no_show=True)
     any_menu=self.dtype_menu(('Range','Window','Dispatch','Action','Method','Routine'),varname='dtype_any',no_show=True)
     menus=(self.dtype_expression,self.dtype_axis,self.dtype_dispatch,self.dtype_action,self.dtype_task,self.dtype_window,self.dtype_any)
     hbtop.pack_start(self.on,False,False,10)
     hbtop.pack_start(self.parent_on,False,False,10)
     hbtop.pack_start(self.path,False,False,0)
     hbtags.pack_start(Label("Tags:"),False,False,10)
     hbtags.pack_start(self.tags,False,False,0)
     self.action=MDSplusActionWidget()
     self.windoww=MDSplusWindowWidget()
     self.sequential=MDSplusSequentialWidget()
     self.expression=MDSplusExpressionWidget()
     self.method=MDSplusMethodWidget()
     self.routine=MDSplusRoutineWidget()
     self.dispatch=MDSplusDispatchWidget()
     self.range=MDSplusRangeWidget()
     self.widgets=(self.action,self.sequential,self.expression,self.method,self.routine,self.dispatch,self.range,self.windoww)
     self.ok=Button(stock=STOCK_OK)
     self.cancel=Button(stock=STOCK_CANCEL)
     self.redo=Button(stock=STOCK_REDO)
     self.ok.connect("clicked",self.do_ok)
     self.cancel.connect("clicked",self.do_cancel)
     self.redo.connect("clicked",self.do_redo)
     hb2=HBox()
     hb2.add(self.ok)
     hb2.add(self.redo)
     hb2.add(self.cancel)
     vb=VBox(homogeneous=False)
     vb.set_border_width(10)
     vb.pack_start(hbtop,False,False,0)
     vb.pack_start(hbtags,False,False,0)
     vb.pack_start(expression_menu,False,False,0)
     vb.pack_start(axis_menu,False,False,0)
     vb.pack_start(window_menu,False,False,0)
     vb.pack_start(dispatch_menu,False,False,0)
     vb.pack_start(action_menu,False,False,0)
     vb.pack_start(task_menu,False,False,0)
     vb.pack_start(any_menu,False,False,0)
     for w in self.widgets:
         w.set_no_show_all(True)
         vb.pack_start(w,False,False,0)
     vb.pack_start(hb2,False,False,20)
     self.add(vb)
     self.do_redo(self.redo)
     self.putOnApply = True
     self.nidOffset = -1
コード例 #50
0
 def __on_plugin_directories_button_click(self, button):
     """Present a dialog to the user for selecting extra plugin directories
     and process the request."""
     
     dia = Dialog('Plugin Directories',
          None, DIALOG_MODAL,
          (STOCK_OK, RESPONSE_OK,
          STOCK_CANCEL, RESPONSE_CANCEL ) )
     dia.resize(500, 300)
     dia.vbox.set_spacing(8)
     
     # Setup the tree view of plugin directories.
     model = ListStore(str) # each row contains a single string
     tv = TreeView(model)
     cell = CellRendererText()
     column = TreeViewColumn('Directory', cell, text = 0)
     tv.append_column(column)
     dia.vbox.pack_start(tv)
     
     # Populate the tree view.
     plugin_directories = \
         get_plugins_directories_from_config(self.config, self.config_path)
     for plugin_directory in plugin_directories:
         row = (plugin_directory,)
         model.append(row)
     
     modify_box = HBox(spacing = 8)
     
     # Setup the remove directory button.
     remove_button = Button('Remove')
     remove_button.set_sensitive(False) # no directory selected initially
     remove_button.connect('clicked', self.__on_remove, tv)
     modify_box.pack_end(remove_button, expand = False)
     
     tv.connect('cursor-changed', self.__on_select, remove_button)
     
     # Setup the add directory button.
     add_button = Button('Add')
     add_button.connect('clicked', self.__on_add, tv)
     modify_box.pack_end(add_button, expand = False)
     
     dia.vbox.pack_start(modify_box, expand = False)
     
     # Setup the "already included directories" label.
     included_label = Label('Plugins in the PYTHONPATH are already ' +
                            'available to BoKeep.')
     # Use a horizontal box to left-justify the label.  For some reason,
     # the label's set_justification property doesn't work for me.
     label_box = HBox()
     label_box.pack_start(included_label, expand = False)
     dia.vbox.pack_start(label_box, expand = False)
     
     dia.show_all()
     dia_result = dia.run()
     
     if dia_result == RESPONSE_OK:            
         # Remove the old plugin directories from the program's path.
         plugin_directories = \
             get_plugins_directories_from_config(self.config,
                                                 self.config_path)
         for plugin_directory in plugin_directories:
             path.remove(plugin_directory)
         
         # Get the new plugin directories from the dialog.
         plugin_directories = []
         for row in model:
             plugin_directory = row[0]
             plugin_directories.append(plugin_directory)
         
         # Update the BoKeep PYTHONPATH so that new plugins can be loaded and
         # populate the list of possible new plugins.
         for plugin_directory in plugin_directories:
             path.append(plugin_directory)
         self.__populate_possible_plugins()
         
         # Save the new plugin directories in the configuration file.
         set_plugin_directories_in_config(self.config,
             self.config_path, plugin_directories)
     
     dia.destroy()