コード例 #1
0
ファイル: ui_user.py プロジェクト: tejastank/simplestock
 def create_ui(self):
     #search
     lbl_search_uname = gtk.Label('User name')
     self.ent_search_uname = gtk.Entry()
     lbl_search_rname = gtk.Label('Real name')
     self.ent_search_rname = gtk.Entry()
     self.combo_search = gtk.combo_box_new_text()
     self.combo_search.append_text('OR')
     self.combo_search.append_text('AND')
     self.combo_search.set_active(0)
     btn_search_do = gtk.Button(stock=gtk.STOCK_FIND)
     btn_search_do.connect('clicked', self.user_search)
     btn_search_clear = gtk.Button(stock=gtk.STOCK_CLEAR)
     btn_search_clear.connect('clicked', self.user_search_clear)
     hb_search = gtk.HBox()
     hb_search.pack_start(lbl_search_uname, padding=4, expand=False)
     hb_search.pack_start(self.ent_search_uname, padding=4)
     hb_search.pack_start(lbl_search_rname, padding=4, expand=False)
     hb_search.pack_start(self.ent_search_rname, padding=4)
     hb_search.pack_start(self.combo_search, padding=4, expand=False)
     hb_search.pack_start(btn_search_do, padding=4, expand=False)
     hb_search.pack_start(btn_search_clear, padding=4, expand=False)
     self.vbox.pack_start(hb_search, padding=10, expand=False)
     #
     #
     scrollw_main = gtk.ScrolledWindow()
     scrollw_main.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     self.lstore_main = gtk.ListStore(str, str, str, str)
     self.trview_main = gtk.TreeView(self.lstore_main)
     self.trview_main.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
     #
     trvcol_main_id = gtk.TreeViewColumn('ID')
     trvcol_main_id.set_min_width(80)
     cell_main_id = gtk.CellRendererText()
     trvcol_main_id.pack_start(cell_main_id, True)
     trvcol_main_id.set_attributes(cell_main_id, text=0)
     trvcol_main_uname = gtk.TreeViewColumn('User Name')
     trvcol_main_uname.set_min_width(140)
     cell_main_uname = gtk.CellRendererText()
     trvcol_main_uname.pack_start(cell_main_uname, True)
     trvcol_main_uname.set_attributes(cell_main_uname, text=1)
     trvcol_main_rname = gtk.TreeViewColumn('Real Name')
     trvcol_main_rname.set_min_width(240)
     cell_main_rname = gtk.CellRendererText()
     trvcol_main_rname.pack_start(cell_main_rname, True)
     trvcol_main_rname.set_attributes(cell_main_rname, text=2)
     trvcol_main_group = gtk.TreeViewColumn('Group')
     trvcol_main_group.set_min_width(140)
     cell_main_group = gtk.CellRendererText()
     trvcol_main_group.pack_start(cell_main_group, True)
     trvcol_main_group.set_attributes(cell_main_group, text=3)
     #
     self.trview_main.append_column(trvcol_main_id)
     self.trview_main.append_column(trvcol_main_uname)
     self.trview_main.append_column(trvcol_main_rname)
     self.trview_main.append_column(trvcol_main_group)
     self.trview_main.set_search_column(1)
     scrollw_main.add(self.trview_main)
     self.vbox.pack_start(scrollw_main)
     #
     self.lbl_main_count = gtk.Label()
     self.lbl_main_count.set_alignment(0.005, 0.5)
     self.vbox.pack_start(self.lbl_main_count, expand=False, padding=10)
     #
     #
     btn_groupedit = gtk.Button('_Group Editor')
     img_groupedit = gtk.Image()
     img_groupedit.set_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON)
     btn_groupedit.set_image(img_groupedit)
     btn_groupedit.connect('clicked', self.group_edit)
     btn_new = gtk.Button(stock=gtk.STOCK_NEW)
     btn_new.connect('clicked', self.user_new)
     btn_edit = gtk.Button(stock=gtk.STOCK_EDIT)
     btn_edit.connect('clicked', self.user_edit)
     btn_del = gtk.Button(stock=gtk.STOCK_DELETE)
     btn_del.connect('clicked', self.user_delete)
     btn_refresh = gtk.Button(stock=gtk.STOCK_REFRESH)
     btn_refresh.connect('clicked', self.user_refresh)
     btnbox = gtk.HButtonBox()
     btnbox.set_layout(gtk.BUTTONBOX_END)
     btnbox.pack_start(btn_groupedit)
     btnbox.pack_start(btn_new)
     btnbox.pack_start(btn_edit)
     btnbox.pack_start(btn_del)
     btnbox.pack_start(btn_refresh)
     btnbox.set_spacing(10)
     #
     hb_action = gtk.HBox()
     hb_action.pack_start(btnbox, padding=10)
     self.vbox.pack_start(hb_action, expand=False, padding=10)
     #
     return self.vbox
コード例 #2
0
    def __init_window(self):
        # Start pyGTK setup
        self.window = gtk.Window()
        self.window.set_title(_("Openbox Logout"))

        self.window.connect("destroy", self.quit)
        self.window.connect("key-press-event", self.on_keypress)
        self.window.connect("window-state-event", self.on_window_state_change)

        if not self.window.is_composited():
            self.logger.debug("No compositing, enabling rendered effects")
            # Window isn't composited, enable rendered effects
            self.rendered_effects = True
        else:
            # Link in Cairo rendering events [disabled]
            #self.window.connect('expose-event', self.on_expose)
            #self.window.connect('screen-changed', self.on_screen_changed)
            #self.on_screen_changed(self.window)
            self.rendered_effects = True

        self.window.set_size_request(620, 200)
        self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))

        self.window.set_decorated(False)
        self.window.set_position(gtk.WIN_POS_CENTER)

        # Create the main panel box
        self.mainpanel = gtk.HBox()

        # Create the button box
        self.buttonpanel = gtk.HButtonBox()
        self.buttonpanel.set_spacing(10)

        # Pack in the button box into the panel box, with two padder boxes
        self.mainpanel.pack_start(gtk.VBox())
        self.mainpanel.pack_start(self.buttonpanel, False, False)
        self.mainpanel.pack_start(gtk.VBox())

        # Add the main panel to the window
        self.window.add(self.mainpanel)

        for button in self.button_list:
            self.__add_button(button, self.buttonpanel)

        if self.rendered_effects == True:
            self.logger.debug("Stepping though render path")
            w = gtk.gdk.get_default_root_window()
            sz = w.get_size()
            pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, sz[0], sz[1])
            pb = pb.get_from_drawable(w, w.get_colormap(), 0, 0, 0, 0, sz[0],
                                      sz[1])

            self.logger.debug("Rendering Fade")
            # Convert Pixbuf to PIL Image
            wh = (pb.get_width(), pb.get_height())
            pilimg = Image.frombytes("RGB", wh, pb.get_pixels())

            pilimg = pilimg.point(lambda p: (p * self.opacity) / 255)

            # "Convert" the PIL to Pixbuf via PixbufLoader
            buf = StringIO.StringIO()
            pilimg.save(buf, "ppm")
            del pilimg
            loader = gtk.gdk.PixbufLoader("pnm")
            loader.write(buf.getvalue())
            pixbuf = loader.get_pixbuf()

            # Cleanup IO
            buf.close()
            loader.close()

            pixmap, mask = pixbuf.render_pixmap_and_mask()
            # width, height = pixmap.get_size()
        else:
            pixmap = None

        self.window.set_app_paintable(True)
        self.window.resize(gtk.gdk.screen_width(), gtk.gdk.screen_height())
        self.window.realize()

        if pixmap:
            self.window.window.set_back_pixmap(pixmap, False)
        self.window.move(0, 0)
コード例 #3
0
import gtk
import pdock
item_count = 0

def add_item(btn, dock):
    global item_count
    item_count += 1
    item = pdock.DockItem(dock, "item%s" % item_count, gtk.TextView(),
                          "Item %s" % item_count, "gtk-ok")
    dock.add_item(item)

win = gtk.Window()
box = gtk.VBox()
win.add(box)

bb = gtk.HButtonBox()
box.pack_start(bb, False, False, 0)

dock = pdock.Dock()
box.pack_start(dock, True, True)


btn = gtk.Button("Add item")
btn.connect("clicked", add_item, dock)
bb.pack_start(btn, False, False, 0)
btn = gtk.Button("Dump")
btn.connect("clicked", lambda w: dock.dump())
bb.pack_start(btn, False, False, 0)
btn = gtk.Button("Quit")
btn.connect("clicked", lambda w: gtk.main_quit())
bb.pack_start(btn, False, False, 0)
コード例 #4
0
ファイル: widMapExport.py プロジェクト: yuviip/GMapCatcher
    def __init__(self):
        super(MapExport, self).__init__()

        vboxCoord = gtk.VBox(False, 5)
        vboxCoord.set_border_width(10)

        self.entryUpperLeft = gtk.Entry()
        self.entryLowerRight = gtk.Entry()

        hbox = gtk.HBox(False)
        vbox = gtk.VBox(False, 5)
        vbox.pack_start(lbl("  Upper Left: "))
        vbox.pack_start(lbl(" Lower Right: "))
        hbox.pack_start(vbox, False, True)
        vbox = gtk.VBox(False, 5)
        vbox.pack_start(self.entryUpperLeft)
        vbox.pack_start(self.entryLowerRight)
        hbox.pack_start(vbox)
        vboxCoord.pack_start(myFrame(" Corners' coordinates ", hbox))

        vboxInput = gtk.VBox(False, 5)
        vboxInput.set_border_width(10)
        vbox = gtk.VBox(False, 20)
        vbox.set_border_width(10)
        hboxSize = gtk.HBox(False, 20)
        hbox = gtk.HBox(False, 5)
        hbox.pack_start(lbl("Width / Height:"), False, True)
        self.sbWidth = SpinBtn(TILES_WIDTH * 4, TILES_WIDTH, 99999,
                               TILES_WIDTH, 5)
        hbox.pack_start(self.sbWidth, False, True)
        hbox.pack_start(lbl("/"), False, True)
        self.sbHeight = SpinBtn(TILES_HEIGHT * 3, TILES_HEIGHT, 99999,
                                TILES_HEIGHT, 5)
        hbox.pack_start(self.sbHeight, False, True)
        hboxSize.pack_start(hbox)
        vbox.pack_start(hboxSize)

        hboxZoom = gtk.HBox(False, 5)
        hboxZoom.pack_start(lbl("    Zoom Level:"), False, True)
        self.expZoom = SpinBtn(6)
        hboxZoom.pack_start(self.expZoom, False, True)
        self.mode = gtk.combo_box_new_text()
        self.mode.append_text("L")
        self.mode.append_text("RGB")
        self.mode.append_text("RGBA")
        self.mode.append_text("RGBX")
        self.mode.append_text("CMYK")
        if os.name == "posix":
            self.mode.set_active(2)
        else:
            self.mode.set_active(1)
        hboxZoom.pack_start(lbl("    Mode:"), False, True)
        hboxZoom.pack_start(self.mode, False, True)
        vbox.pack_start(hboxZoom)

        self.button = gtk.Button(stock='gtk-ok')
        hboxInput = gtk.HBox(False, 5)
        hboxInput.pack_start(vbox)
        bbox = gtk.HButtonBox()
        bbox.add(self.button)
        hboxInput.pack_start(bbox)
        vboxInput.pack_start(myFrame(" Image settings ", hboxInput))

        self.export_box = gtk.HBox(False, 5)
        self.export_box.pack_start(vboxCoord)
        self.export_box.pack_start(vboxInput)
        self.export_pbar = ProgressBar(" Exporting... ")
        hbox = gtk.HBox(False, 5)
        hbox.pack_start(self.export_box)
        hbox.pack_start(self.export_pbar)

        vFbox = gtk.VBox(False, 5)
        vFbox.set_border_width(5)
        vFbox.pack_start(hbox)
        self.add(vFbox)
        self.set_label(" Export map to PNG image ")
コード例 #5
0
ファイル: mirrors.py プロジェクト: pombreda/smart
    def __init__(self, parent=None):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("Mirrors"))
        self._window.set_modal(True)
        self._window.set_transient_for(parent)
        self._window.set_position(gtk.WIN_POS_CENTER)
        self._window.set_geometry_hints(min_width=600, min_height=400)

        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
        sw.set_shadow_type(gtk.SHADOW_IN)
        sw.show()
        vbox.add(sw)

        self._treemodel = gtk.TreeStore(gobject.TYPE_STRING)
        self._treeview = gtk.TreeView(self._treemodel)
        self._treeview.set_rules_hint(True)
        self._treeview.set_headers_visible(False)
        self._treeview.show()
        sw.add(self._treeview)

        renderer = gtk.CellRendererText()
        renderer.set_property("xpad", 3)
        renderer.set_property("editable", True)
        renderer.connect("edited", self.rowEdited)
        self._treeview.insert_column_with_attributes(-1,
                                                     _("Mirror"),
                                                     renderer,
                                                     text=0)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        button = gtk.Button(stock="gtk-new")
        button.show()
        button.connect("clicked", lambda x: self.newMirror())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-delete")
        button.show()
        button.connect("clicked", lambda x: self.delMirror())
        bbox.pack_start(button)

        button = gtk.Button(stock="gtk-close")
        button.show()
        button.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(button)
コード例 #6
0
    def createMainWindow(self):
        """Create and initialize the main window.  This includes switching to
           fullscreen mode if necessary, adding buttons, displaying artwork,
           and other functions.  This method should also create the UI elements
           that make up the sidebar.  This method returns a gtk.Window.
        """
        # Create the initial window and a vbox to fill it with.
        self.win = gtk.Window()
        self.win.set_position(gtk.WIN_POS_NONE)
        self.win.set_decorated(False)
        # we don't set border width here so that the sidebar will meet
        # the edge of the screen

        self.fit_window_to_screen()

        # Create a box that will hold all other widgets.
        self.mainHBox = gtk.HBox(False, 10)

        # Create the sidebar box.
        self.sidebar = gtk.VBox()
        self.sidebar.set_border_width(24)

        # Load this background now so we can figure out how big to make
        # the left side.
        try:
            self.sidebarBg = loadPixbuf(
                "%s/%s" % (config.themeDir, "firstboot-left.png"))
        except:
            self.sidebarBg = loadPixbuf(
                "%s/%s" % (config.defaultThemeDir, "firstboot-left.png"))

        self.aspectRatio = (1.0 * self.sidebarBg.get_width()) / (
            1.0 * self.sidebarBg.get_height())

        # leftEventBox exists only so we have somewhere to paint an image.
        self.leftEventBox = gtk.EventBox()
        self.leftEventBox.add(self.sidebar)
        self.sidebar.connect("expose-event", self._sidebarExposed)

        # Create the box for the right side of the screen.  This holds the
        # display for the current module and the button box.
        self.rightBox = gtk.VBox()
        self.rightBox.set_border_width(24)

        leftWidth = int(self._y_size * self.aspectRatio)
        self.leftEventBox.set_size_request(leftWidth, self._y_size)
        self.win.fullscreen()

        # Create a button box to handle navigation.
        self.buttonBox = gtk.HButtonBox()
        self.buttonBox.set_layout(gtk.BUTTONBOX_END)
        self.buttonBox.set_spacing(10)
        self.buttonBox.set_border_width(10)

        # Create the Back button, marking it insensitive by default since we
        # start at the first page.
        self.backButton = gtk.Button(use_underline=True,
                                     stock="gtk-go-back",
                                     label=_("_Back"))
        self._setBackSensitivity()
        self.backButton.connect("clicked", self._backClicked)
        self.buttonBox.pack_start(self.backButton)

        # Create the Forward button.
        self.nextButton = gtk.Button(use_underline=True,
                                     stock="gtk-go-forward",
                                     label=_("_Forward"))
        self.nextButton.connect("clicked", self._nextClicked)
        self.buttonBox.pack_start(self.nextButton)

        # Add the widgets into the right side.
        self.rightBox.pack_end(self.buttonBox, expand=False)

        # Add the widgets into the main hbox widget.
        self.mainHBox.pack_start(self.leftEventBox, expand=False, fill=False)
        self.mainHBox.pack_start(self.rightBox, expand=True, fill=True)

        self.win.add(self.mainHBox)
        self.win.connect("destroy", self.destroy)
        self.win.connect("key-release-event", self._keyRelease)

        return self.win
コード例 #7
0
ファイル: __init__.py プロジェクト: hjq300/zim-wiki
	def __init__(self, ui, vcs, notebook, page=None):
		Dialog.__init__(self, ui, _('Versions'), # T: dialog title
			buttons=gtk.BUTTONS_CLOSE, help='Plugins:Version Control')
		self.notebook = notebook
		self.vcs = vcs
		self._side_by_side_app = get_side_by_side_app()

		self.uistate.setdefault('windowsize', (600, 500), check=value_is_coord)
		self.uistate.setdefault('vpanepos', 300)

		self.vpaned = VPaned()
		self.vpaned.set_position(self.uistate['vpanepos'])
		self.vbox.add(self.vpaned)

		vbox = gtk.VBox(spacing=5)
		self.vpaned.pack1(vbox, resize=True)

		# Choice between whole notebook or page
		label = gtk.Label('<b>'+_('Versions')+':</b>') # section label
		label.set_use_markup(True)
		label.set_alignment(0, 0.5)
		vbox.pack_start(label, False)

		self.notebook_radio = gtk.RadioButton(None, _('Complete _notebook'))
			# T: Option in versions dialog to show version for complete notebook
		self.page_radio = gtk.RadioButton(self.notebook_radio, _('_Page')+':')
			# T: Option in versions dialog to show version for single page
		#~ recursive_box = gtk.CheckButton('Recursive')
		vbox.pack_start(self.notebook_radio, False)

		# Page entry
		hbox = gtk.HBox(spacing=5)
		vbox.pack_start(hbox, False)
		hbox.pack_start(self.page_radio, False)
		self.page_entry = PageEntry(self.notebook)
		if page:
			self.page_entry.set_path(page)
		hbox.pack_start(self.page_entry, False)

		# View annotated button
		ann_button = gtk.Button(_('View _Annotated')) # T: Button label
		ann_button.connect('clicked', lambda o: self.show_annotated())
		hbox.pack_start(ann_button, False)

		# Help text
		label = gtk.Label('<i>\n'+_( '''\
Select a version to see changes between that version and the current
state. Or select multiple versions to see changes between those versions.
''' ).strip()+'</i>') # T: Help text in versions dialog
		label.set_use_markup(True)
		#~ label.set_alignment(0, 0.5)
		vbox.pack_start(label, False)

		# Version list
		self.versionlist = VersionsTreeView()
		self.versionlist.load_versions(vcs.list_versions())
		scrolled = ScrolledWindow(self.versionlist)
		vbox.add(scrolled)

		col = self.uistate.setdefault('sortcol', self.versionlist.REV_SORT_COL)
		order = self.uistate.setdefault('sortorder', gtk.SORT_DESCENDING)
		try:
			self.versionlist.get_model().set_sort_column_id(col, order)
		except:
			logger.exception('Invalid sort column: %s %s', col, order)

		# -----
		vbox = gtk.VBox(spacing=5)
		self.vpaned.pack2(vbox, resize=False)

		label = gtk.Label('<b>'+_('Comment')+'</b>') # T: version details
		label.set_use_markup(True)
		label.set_alignment(0.0, 0.5)
		vbox.pack_start(label, False)

		# Comment text
		window, textview = ScrolledTextView()
		self.comment_textview = textview
		vbox.add(window)

		buttonbox = gtk.HButtonBox()
		buttonbox.set_layout(gtk.BUTTONBOX_END)
		vbox.pack_start(buttonbox, False)

		# Restore version button
		revert_button = gtk.Button(_('_Restore Version')) # T: Button label
		revert_button.connect('clicked', lambda o: self.restore_version())
		buttonbox.add(revert_button)

		# Notebook Changes button
		diff_button = gtk.Button(_('Show _Changes'))
			# T: button in versions dialog for diff
		diff_button.connect('clicked', lambda o: self.show_changes())
		buttonbox.add(diff_button)

		# Compare page button
		comp_button = gtk.Button(_('_Side by Side'))
			# T: button in versions dialog for side by side comparison
		comp_button.connect('clicked', lambda o: self.show_side_by_side())
		buttonbox.add(comp_button)


		# UI interaction between selections and buttons

		def on_row_activated(o, iter, path):
			model = self.versionlist.get_model()
			comment = model[iter][VersionsTreeView.MSG_COL]
			buffer = textview.get_buffer()
			buffer.set_text(comment)

		self.versionlist.connect('row-activated', on_row_activated)


		def on_ui_change(o):
			usepage = self.page_radio.get_active()
			self.page_entry.set_sensitive(usepage)
			ann_button.set_sensitive(usepage)

			# side by side comparison can only be done for one page
			# revert can only be done to one version, not multiple
			selection = self.versionlist.get_selection()
			model, rows = selection.get_selected_rows()
			if not rows:
				revert_button.set_sensitive(False)
				diff_button.set_sensitive(False)
				comp_button.set_sensitive(False)
			elif len(rows) == 1:
				revert_button.set_sensitive(usepage)
				diff_button.set_sensitive(True)
				comp_button.set_sensitive(bool(usepage and self._side_by_side_app))
			else:
				revert_button.set_sensitive(False)
				diff_button.set_sensitive(True)
				comp_button.set_sensitive(bool(usepage and self._side_by_side_app))

		def on_page_change(o):
			pagesource = self._get_file()
			if pagesource:
				self.versionlist.load_versions(vcs.list_versions(self._get_file()))

		def on_book_change(o):
			self.versionlist.load_versions(vcs.list_versions())

		self.page_radio.connect('toggled', on_ui_change)
		self.notebook_radio.connect('toggled', on_book_change)
		self.page_radio.connect('toggled', on_page_change)
		self.page_entry.connect('changed', on_page_change)
		selection = self.versionlist.get_selection()
		selection.connect('changed', on_ui_change)

		# select last version
		self.versionlist.get_selection().select_path((0,))
		col = self.versionlist.get_column(0)
		self.versionlist.row_activated(0, col)
コード例 #8
0
ファイル: takeimage.py プロジェクト: so-artn/rts2-gtk
    def __init__(self, camera_name, client_only):
        gtk.Window.__init__(self)
        self.camera_name = camera_name
        self.client_only = client_only

        if self.client_only:
            self.set_title(_('Client for camera {0}').format(self.camera_name))
        else:
            self.set_title(
                _('Images from camera {0}').format(self.camera_name))

        vb = gtk.VBox()

        tt = gtk.Table(2, 7)
        tt.set_col_spacings(10)
        tt.set_row_spacings(10)

        def ll(text):
            l = gtk.Label(text)
            l.set_alignment(1, 0.5)
            return l

        self.status = gtk.Label('IDLE')
        vb.pack_start(self.status, False, False)

        if not self.client_only:
            tt.attach(ll(_('Exposure time')), 0, 1, 0, 1)
            self.exp_t = gtk.SpinButton(gtk.Adjustment(1, 0, 86400, 1, 10),
                                        digits=2)
            tt.attach(self.exp_t, 1, 2, 0, 1)

            tt.attach(ll(_('Binning')), 0, 1, 1, 2)

            bins = login.getProxy().getSelection(self.camera_name, 'binning')

            self.binnings = []
            hb = gtk.HBox()

            nb = gtk.RadioButton(None, bins[0])
            self.binnings.append(nb)
            hb.pack_start(nb, False, False)
            nb.connect('clicked', self.set_binning)

            for b in bins[1:]:
                nb = gtk.RadioButton(self.binnings[0], b)
                self.binnings.append(nb)
                hb.pack_start(nb, False, False)
                nb.connect('clicked', self.set_binning)

            tt.attach(hb, 1, 2, 1, 2)

        tt.attach(ll(_('Channel')), 0, 1, 2, 3)
        ahb = gtk.HButtonBox()
        self.exp_c = []
        self.sofar = []
        self.tb = []

        try:
            chan = login.getProxy().getValue(self.camera_name, 'CHAN')
        except KeyError, ke:
            chan = [True]
コード例 #9
0
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.set_border_width(6)
        self.set_resizable(False)
        self.set_title('')
        # defaults to center location
        self.set_position(gtk.WIN_POS_CENTER)
        self.connect("delete-event", self.__on_close)

        # main container
        main = gtk.VBox(spacing=12)
        main.set_spacing(12)
        main.set_border_width(6)
        main.show()
        self.add(main)

        # primary text
        alg = gtk.Alignment()
        alg.set_padding(0, 6, 0, 0)
        alg.show()
        main.pack_start(alg, False, False)
        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        self.__primary_label = lbl
        alg.add(lbl)

        # secondary text
        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        main.pack_start(lbl, False, False)
        self.__secondary_label = lbl

        # Progress bar
        vbox = gtk.VBox()
        vbox.show()
        main.pack_start(vbox, False, False)

        prog = gtk.ProgressBar()
        prog.show()
        self.__progress_bar = prog
        vbox.pack_start(prog, expand=False)

        lbl = hig_label()
        lbl.set_selectable(False)
        lbl.show()
        self.__sub_progress_label = lbl
        vbox.pack_start(lbl, False, False)

        # Buttons box
        bbox = gtk.HButtonBox()
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()

        # Cancel Button
        cancel = gtk.Button(gtk.STOCK_CANCEL)
        cancel.set_use_stock(True)
        cancel.show()
        self.__cancel = cancel
        bbox.add(cancel)
        main.add(bbox)

        # Close button, which is hidden by default
        close = gtk.Button(gtk.STOCK_CLOSE)
        close.set_use_stock(True)
        close.hide()
        bbox.add(close)
        self.__close = close
コード例 #10
0
    def build_ui(self):
        self.clear_ui()

        self.box = gtk.VBox(False, 20)
        self.configure_window()
        self.window.add(self.box)

        if 'error' in self.gui:
            # labels
            self.label = gtk.Label(self.gui_message)
            self.label.set_line_wrap(True)
            self.box.pack_start(self.label, True, True, 0)
            self.label.show()

            # button box
            self.button_box = gtk.HButtonBox()
            self.button_box.set_layout(gtk.BUTTONBOX_SPREAD)
            self.box.pack_start(self.button_box, True, True, 0)
            self.button_box.show()

            if self.gui != 'error':
                # yes button
                yes_image = gtk.Image()
                yes_image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
                self.yes_button = gtk.Button("Yes")
                self.yes_button.set_image(yes_image)
                if self.gui == 'error_try_stable':
                    self.yes_button.connect("clicked", self.try_stable, None)
                elif self.gui == 'error_try_default_mirror':
                    self.yes_button.connect("clicked", self.try_default_mirror,
                                            None)
                elif self.gui == 'error_try_tor':
                    self.yes_button.connect("clicked", self.try_tor, None)
                self.button_box.add(self.yes_button)
                self.yes_button.show()

            # exit button
            exit_image = gtk.Image()
            exit_image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON)
            self.exit_button = gtk.Button("Exit")
            self.exit_button.set_image(exit_image)
            self.exit_button.connect("clicked", self.destroy, None)
            self.button_box.add(self.exit_button)
            self.exit_button.show()

        elif self.gui == 'task':
            # label
            self.label = gtk.Label(self.gui_message)
            self.label.set_line_wrap(True)
            self.box.pack_start(self.label, True, True, 0)
            self.label.show()

            # progress bar
            self.progressbar = gtk.ProgressBar(adjustment=None)
            self.progressbar.set_orientation(gtk.PROGRESS_LEFT_TO_RIGHT)
            self.progressbar.set_pulse_step(0.01)
            self.box.pack_start(self.progressbar, True, True, 0)

            # button box
            self.button_box = gtk.HButtonBox()
            self.button_box.set_layout(gtk.BUTTONBOX_SPREAD)
            self.box.pack_start(self.button_box, True, True, 0)
            self.button_box.show()

            # start button
            start_image = gtk.Image()
            start_image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
            self.start_button = gtk.Button(_("Start"))
            self.start_button.set_image(start_image)
            self.start_button.connect("clicked", self.start, None)
            self.button_box.add(self.start_button)
            if not self.gui_autostart:
                self.start_button.show()

            # exit button
            exit_image = gtk.Image()
            exit_image.set_from_stock(gtk.STOCK_CANCEL, gtk.ICON_SIZE_BUTTON)
            self.exit_button = gtk.Button(_("Cancel"))
            self.exit_button.set_image(exit_image)
            self.exit_button.connect("clicked", self.destroy, None)
            self.button_box.add(self.exit_button)
            self.exit_button.show()

        self.box.show()
        self.window.show()

        if self.gui_autostart:
            self.start(None)
コード例 #11
0
ファイル: takeimage.py プロジェクト: so-artn/rts2-gtk
class CameraWindow(gtk.Window):
    def __init__(self, camera_name, client_only):
        gtk.Window.__init__(self)
        self.camera_name = camera_name
        self.client_only = client_only

        if self.client_only:
            self.set_title(_('Client for camera {0}').format(self.camera_name))
        else:
            self.set_title(
                _('Images from camera {0}').format(self.camera_name))

        vb = gtk.VBox()

        tt = gtk.Table(2, 7)
        tt.set_col_spacings(10)
        tt.set_row_spacings(10)

        def ll(text):
            l = gtk.Label(text)
            l.set_alignment(1, 0.5)
            return l

        self.status = gtk.Label('IDLE')
        vb.pack_start(self.status, False, False)

        if not self.client_only:
            tt.attach(ll(_('Exposure time')), 0, 1, 0, 1)
            self.exp_t = gtk.SpinButton(gtk.Adjustment(1, 0, 86400, 1, 10),
                                        digits=2)
            tt.attach(self.exp_t, 1, 2, 0, 1)

            tt.attach(ll(_('Binning')), 0, 1, 1, 2)

            bins = login.getProxy().getSelection(self.camera_name, 'binning')

            self.binnings = []
            hb = gtk.HBox()

            nb = gtk.RadioButton(None, bins[0])
            self.binnings.append(nb)
            hb.pack_start(nb, False, False)
            nb.connect('clicked', self.set_binning)

            for b in bins[1:]:
                nb = gtk.RadioButton(self.binnings[0], b)
                self.binnings.append(nb)
                hb.pack_start(nb, False, False)
                nb.connect('clicked', self.set_binning)

            tt.attach(hb, 1, 2, 1, 2)

        tt.attach(ll(_('Channel')), 0, 1, 2, 3)
        ahb = gtk.HButtonBox()
        self.exp_c = []
        self.sofar = []
        self.tb = []

        try:
            chan = login.getProxy().getValue(self.camera_name, 'CHAN')
        except KeyError, ke:
            chan = [True]
        chn = 1
        for x in chan:
            ach = gtk.CheckButton(str(chn))
            ach.set_active(x)
            ahb.add(ach)
            self.exp_c.append(ach)
            self.sofar.append(0)
            self.tb.append(0)
            chn += 1
        tt.attach(ahb, 1, 2, 2, 3)

        self.not_orient = [True] * len(chan)

        tt.attach(ll(_('Convert')), 0, 1, 3, 4)
        vb2 = gtk.VBox()
        hb = gtk.HBox()

        self.df_keep = gtk.RadioButton(None, 'Keep')
        hb.pack_start(self.df_keep, False, False)

        self.df_8b = gtk.RadioButton(self.df_keep, '8bit')
        hb.pack_start(self.df_8b, False, False)

        self.df_16b = gtk.RadioButton(self.df_keep, '16bit')
        hb.pack_start(self.df_16b, False, False)

        vb2.pack_start(hb, False, False)

        hb = gtk.HBox()
        self.smin = gtk.SpinButton(gtk.Adjustment(1, 0, 0xffff, 1, 10),
                                   digits=0)
        self.smax = gtk.SpinButton(gtk.Adjustment(1, 0, 0xffff, 1, 10),
                                   digits=0)

        hb.pack_start(self.smin, False, False)
        hb.pack_start(self.smax, False, False)

        vb2.pack_end(hb, False, False)

        tt.attach(vb2, 1, 2, 3, 4)

        tt.attach(ll(_('Exposure')), 0, 1, 4, 5)
        self.exp_p = gtk.ProgressBar()
        tt.attach(self.exp_p, 1, 2, 4, 5)

        tt.attach(ll(_('Readout')), 0, 1, 5, 6)
        self.readout_p = gtk.ProgressBar()
        tt.attach(self.readout_p, 1, 2, 5, 6)

        tt.attach(ll(_('Data')), 0, 1, 6, 7)
        avb = gtk.VBox()
        self.data_pbs = []
        for x in chan:
            apb = gtk.ProgressBar()
            avb.add(apb)
            self.data_pbs.append(apb)
        tt.attach(avb, 1, 2, 6, 7)

        vb.pack_start(tt, False, False)

        bb = gtk.HButtonBox()
        if self.client_only:
            self.current_b = gtk.Button(label=_('_Current image'))
            self.current_b.connect('clicked', self.grab_current)
            bb.add(self.current_b)

            self.last_b = gtk.Button(label=_('_Last image'))
            self.last_b.connect('clicked', self.grab_last)
            bb.add(self.last_b)

        else:
            self.exposure_b = gtk.Button(label=_('_Take 1'))
            self.exposure_b.connect('clicked', self.start_exposure)
            bb.add(self.exposure_b)

            self.start_b = gtk.Button(label=_('_Start'))
            self.start_b.connect('clicked', self.start_exposure)
            bb.add(self.start_b)

        self.stop_b = gtk.Button(label=_('_Stop'))
        self.stop_b.connect('clicked', self.stop_exposure)
        self.stop_b.set_sensitive(False)
        bb.add(self.stop_b)

        vb.pack_end(bb, False, False)

        self.add(vb)
        self.show_all()

        self.sta = login.getProxy().loadJson('/api/get',
                                             {'d': self.camera_name})

        self.d = None
        self.exp_conn = None

        self.last_lo = 0
        self.last_hi = 1
        self.exptime = None

        try:
            import numpy
            import ds9
            if self.client_only:
                self.d = ds9.ds9(self.camera_name + 'ti-client')
            else:
                self.d = ds9.ds9(self.camera_name + 'ti')
            # map RTS2 data types to numpy types
            self.ds_lock = threading.Lock()

            self.rts2_2_numpy = {
                8: numpy.uint8,
                16: numpy.int16,
                32: numpy.int32,
                64: numpy.int64,
                -32: numpy.float,
                -64: numpy.double,
                10: numpy.uint8,
                20: numpy.uint16,
                40: numpy.uint32
            }
        except Exception, ex:
            print _(
                "numpy or pyds9 module not present, the program will only take images"
            )
コード例 #12
0
 def __init__(self, name, columns, observer=None):
     self.observer = observer
     #Treeview, columns, cells and model
     args = [gobject.TYPE_STRING] * len(columns)
     self.model = gtk.ListStore(*args)
     self.columns = []
     self.cells = []
     index = 0
     for i in columns:
         cell = gtk.CellRendererText()
         cell.set_property('editable', True)
         cell.connect("edited", self.editing_done, index)
         cell.connect("editing-started", self.__editing_started, index)
         cell.connect("editing-canceled", self.__editing_canceled)
         self.cells.append(cell)
         column = gtk.TreeViewColumn(i, cell, text = index) #map cell to model
         column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
         column.set_expand(True)
         self.columns.append(column)
         index += 1
     self.treeview = gtk.TreeView(model=self.model)
     self.treeview.set_headers_visible(True)
     self.treeview.set_reorderable(True)
     self.model.connect("row-changed", self.__row_changed)
     for c in self.columns:
         self.treeview.append_column(c)
     #Scrolled Window
     self.scrolled_window = gtk.ScrolledWindow()
     self.scrolled_window.add(self.treeview)
     #Actions
     self.action_add = gtk.Action(
          "actionAdd" + name.title(),
          "Add", "Add a new item", gtk.STOCK_ADD
     )
     self.action_remove = gtk.Action(
          "actionRemove" + name.title(),
          "Remove", "Removes selected item", gtk.STOCK_REMOVE
     )
     self.action_add.connect("activate", self.add_event)
     self.action_remove.connect("activate", self.remove_event)
     self.action_remove.set_sensitive(False)
     #Buttons Add and Remove
     self.button_add = gtk.Button(stock=gtk.STOCK_ADD)
     self.button_add.set_related_action(self.action_add)
     self.button_add.set_use_action_appearance(True)
     self.button_remove = gtk.Button(stock=gtk.STOCK_REMOVE)
     self.button_remove.set_related_action(self.action_remove)
     self.button_remove.set_use_action_appearance(True)
     #Button box
     self.hbuttonbox = gtk.HButtonBox()
     self.hbuttonbox.set_layout(gtk.BUTTONBOX_END)
     self.hbuttonbox.set_spacing(15)
     self.hbuttonbox.pack_start(self.button_add)
     self.hbuttonbox.pack_start(self.button_remove)
     #Vertical Box
     self.vbox = gtk.VBox()
     self.vbox.pack_start(self.scrolled_window)
     self.vbox.pack_start(self.hbuttonbox)
     self.vbox.set_child_packing(
         self.hbuttonbox, expand=False, fill=True,
         padding = 0, pack_type=gtk.PACK_START)
コード例 #13
0
 def _create_widgets(self):
     self.vbox = HIGVBox()
     self.btn_box = gtk.HButtonBox()
     self.btn_open = HIGButton(stock=gtk.STOCK_OPEN)
     self.btn_close = HIGButton(stock=gtk.STOCK_CLOSE)
     self.search_gui = SearchGUI(self.notebook)
コード例 #14
0
 def __init__(self):
     locale.setlocale(locale.LC_ALL, "")
     self.name = sugar.profile.get_nick_name()
     self.user_interaction = gtk.VBox()
     self.activity = gtk.Notebook()
     self.activity.set_show_tabs(False)
     self.activity.set_size_request(800, 600)
     self.user_interaction.pack_start(self.activity, False, False, 10)
     # navigation
     self.navigation = gtk.HButtonBox()
     self.user_interaction.pack_start(self.navigation, False, False, 10)
     self.navigation.pack_start(gtk.Label(), False, False, 10)
     self.play = gtk.Button("Play")
     self.navigation.pack_start(self.play, False, False, 10)
     self.play.connect("clicked", self.play_clicked)
     self.help = gtk.Button("Help")
     self.help.connect("clicked", self.help_clicked)
     self.navigation.pack_start(self.help, False, False, 10)
     self.back = gtk.Button("Back")
     self.back.connect("clicked", self.back_clicked)
     self.navigation.pack_start(self.back, False, False, 10)
     self.next = gtk.Button("Next")
     self.next.connect("clicked", self.next_clicked)
     self.navigation.pack_start(self.next, False, False, 10)
     self.navigation.pack_start(gtk.Label(), False, False, 10)
     #
     # create the intro tab
     self.intro_tab = gtk.VBox()
     self.activity.append_page(self.intro_tab)
     # intro - heading
     self.intro_heading = gtk.Label()
     self.intro_heading.set_markup(
         "<big>Let's round numbers with Hoppy the Grasshopper</big>")
     self.intro_tab.pack_start(self.intro_heading, False, False, 10)
     # intro - intro area
     self.intro_area = gtk.HBox()
     self.intro_tab.pack_start(self.intro_area, False, False, 10)
     # intro - image
     self.image_intro = gtk.Image()
     self.intro_area.pack_start(self.image_intro, False, False, 10)
     self.image_intro.set_from_pixbuf(
         gtk.gdk.pixbuf_new_from_file("hoppy-title.svg"))
     # intro - text tabs
     self.introduction = gtk.Notebook()
     self.introduction.set_show_tabs(False)
     self.intro_area.pack_start(self.introduction, False, False, 10)
     self.intro_tab1 = gtk.Label()
     self.intro_tab1.set_line_wrap(True)
     self.intro_tab1.set_size_request(700, 300)
     self.intro_tab1.set_markup(
         "<big>When Hoppy brags to his friends, he likes to tell them how many leaves he can eat in one day.\n\n\nWhen he doesn't know the <b>exact</b> number, he <b>estimates</b>.\n\n\nThis is called <b>rounding</b>.</big>"
     )
     self.introduction.append_page(self.intro_tab1)
     self.intro_tab2 = gtk.Label()
     self.intro_tab2.set_line_wrap(True)
     self.intro_tab2.set_size_request(700, 300)
     self.intro_tab2.set_markup(
         "<big><b>Hoppy says there are two rules for rounding numbers:</b>\n\n\n1.  If the number you are rounding is followed \n\tby <b>5, 6, 7, 8 or 9</b> round the number <b>up</b>.\n\n\tExample:  38 rounded to the nearest ten is 40.\n\n\n2.  If the number you are rounding is followed \n\tby <b>0, 1, 2, 3 or 4</b> round the number <b>down</b>.\n\n\tExample:  33 rounded to the nearest ten is 30.</big>"
     )
     self.introduction.append_page(self.intro_tab2)
     self.intro_tab3 = gtk.Label()
     self.intro_tab3.set_line_wrap(True)
     self.intro_tab3.set_size_request(700, 300)
     self.intro_tab3.set_markup(
         "<big><b>Look at the number 182,727:</b>\n\n\t182,727 rounded to the nearest <b>ten</b> is 182,730\n\t182,727 rounded to the nearest <b>hundred</b> is 182,700\n\t182,727 rounded to the nearest <b>thousand</b> is 183,000\n\t182,727 rounded to the nearest <b>ten thousand</b> is 180,000\n\t182,727 rounded to the nearest <b>hundred thousand</b> is 200,000\n\n\nAll the numbers to the right of the place that you are <b>rounding to</b> become zeros.\n\n\t34 rounded to the nearest <b>ten</b> is 30\n\t4,654 rounded to the nearest <b>hundred</b> is 4,700\n\t986 rounded to the nearest <b>thousand</b> is 1,000\n\t219,526 rounded to the nearest <b>ten thousand</b> is 220,000\n\t742,899 rounded to the nearest <b>hundred thousand</b> is 700,000</big>"
     )
     self.introduction.append_page(self.intro_tab3)
     #
     # create the quiz tab
     self.quiz_tab = gtk.HBox()
     self.activity.append_page(self.quiz_tab)
     self.user_input = gtk.VBox()
     self.quiz_tab.pack_start(self.user_input, False, False, 10)
     self.rounding_phrase = gtk.Label("rounding phrase")
     self.user_input.pack_start(self.rounding_phrase, False, False, 10)
     # quiz - create the play notebook to show the widgets for playing
     self.tabber = gtk.Notebook()
     self.tabber.set_show_tabs(False)
     self.user_input.pack_start(self.tabber, False, False, 10)
     # quiz - create the slider tab
     self.slider_tab = gtk.VButtonBox()
     self.slider_instruction = gtk.Label()
     self.slider_instruction.set_markup(
         "<big>Move the slider to choose the correct answer</big>")
     self.slider_tab.pack_start(self.slider_instruction, False, False, 10)
     self.slider_adjustment = gtk.Adjustment()
     self.slider_tool = gtk.HScale(self.slider_adjustment)
     self.slider_tool.set_digits(0)
     self.slider_tab.pack_start(self.slider_tool, False, False, 10)
     self.slider_click = gtk.Button("OK")
     self.slider_tab.pack_start(self.slider_click, False, False, 10)
     self.tabber.append_page(self.slider_tab)
     # quiz - create the multiple choice tab
     self.mult_tab = gtk.VBox()
     self.mult_instruction = gtk.Label()
     self.mult_instruction.set_markup(
         "<big>Choose one of the answers below</big>")
     self.mult_tab.pack_start(self.mult_instruction, False, False, 10)
     self.mult_1 = gtk.Button()
     self.mult_1.unset_flags(gtk.CAN_FOCUS)
     self.mult_tab.pack_start(self.mult_1, False, False, 10)
     self.mult_2 = gtk.Button()
     self.mult_2.unset_flags(gtk.CAN_FOCUS)
     self.mult_tab.pack_start(self.mult_2, False, False, 10)
     self.mult_3 = gtk.Button()
     self.mult_3.unset_flags(gtk.CAN_FOCUS)
     self.mult_tab.pack_start(self.mult_3, False, False, 10)
     self.mult_4 = gtk.Button()
     self.mult_4.unset_flags(gtk.CAN_FOCUS)
     self.mult_tab.pack_start(self.mult_4, False, False, 10)
     self.tabber.append_page(self.mult_tab)
     # quiz - create the entry tab
     self.entry_tab = gtk.VButtonBox()
     self.entry_instruction = gtk.Label()
     self.entry_instruction.set_markup(
         "<big>Type your answer below and click 'OK'</big>")
     self.entry_tab.pack_start(self.entry_instruction, False, False, 10)
     self.entry_tool = gtk.Entry()
     self.entry_tab.pack_start(self.entry_tool, False, False, 10)
     self.entry_click = gtk.Button("OK")
     self.entry_tab.pack_start(self.entry_click, False, False, 10)
     self.tabber.append_page(self.entry_tab)
     # quiz - create the output
     self.user_output = gtk.VBox()
     self.quiz_tab.pack_start(self.user_output, False, False, 10)
     self.output = gtk.Label("")
     self.output.set_alignment(0.1, 0.5)
     self.user_output.pack_start(self.output, False, False, 10)
     self.image_output = gtk.Image()
     self.user_output.pack_start(self.image_output, False, False, 10)
     self.image_correct_answer = gtk.gdk.pixbuf_new_from_file(
         "hoppy-right.svg")
     self.image_incorrect_answer = gtk.gdk.pixbuf_new_from_file(
         "hoppy-wrong.svg")
コード例 #15
0
ファイル: mpinfo.py プロジェクト: zenny/Galicaster
    def __init__(self, key, parent=None):
        if not parent:
            parent = context.get_mainwindow()
        size = context.get_mainwindow().get_size()
        self.wprop = size[0] / 1920.0
        self.hprop = size[1] / 1080.0
        width = int(size[0] / 3)
        height = int(size[1] / 2.5)

        gtk.Window.__init__(self)
        self.set_title(_("Mediapackage Info "))
        self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
        self.set_default_size(width, height)
        self.set_modal(True)
        if parent:
            self.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
            self.set_transient_for(parent)
            self.set_destroy_with_parent(True)

        # INFO
        mp = context.get_repository().get(key)

        # Metadata info
        data = {}
        data['title'] = mp.title
        data['identifier'] = mp.identifier
        data['folder'] = mp.getURI()
        data['duration'] = readable.time(int(mp.getDuration()) / 1000)
        data['size'] = readable.size(mp.getSize())
        data['created'] = readable.date(mp.getStartDateAsString(),
                                        "%B %d, %Y - %H:%M").replace(
                                            ' 0', ' ')

        basic, basic_table = self.add_framed_table(_("Basic"))
        for item in ORDER_EPISODES:
            if item in data:
                self.add_data(basic_table, EPISODE_NAMES[item], data[item])
            elif item in mp.metadata_episode:
                self.add_data(basic_table, EPISODE_NAMES[item],
                              mp.metadata_episode[item])

        # Operations info
        ops, ops_table = self.add_framed_table(_("Operations"))
        self.add_data(ops_table, _("Ingest:"),
                      mediapackage.op_status[mp.getOpStatus("ingest")])
        self.add_data(ops_table, _("Zipping:"),
                      mediapackage.op_status[mp.getOpStatus("exporttozip")])
        self.add_data(ops_table, _("Side by Side:"),
                      mediapackage.op_status[mp.getOpStatus("sidebyside")])

        # Series info
        if mp.getSeries():
            series, series_table = self.add_framed_table(_("Series"))
            for item in ORDER_SERIES:
                if item in mp.metadata_series:
                    self.add_data(series_table, SERIES_NAMES[item],
                                  mp.metadata_series[item])

        # Track info
        tracks, track_table = self.add_framed_table(_("Tracks"), True)
        first = True
        for track in mp.getTracks():
            if not first:
                self.add_data(track_table, "", "")
            first = False
            self.add_data(track_table, _("Name:"), track.getIdentifier())
            self.add_data(track_table, _("Flavor:"), track.getFlavor())
            self.add_data(track_table, _("Type:"), track.getMimeType())
            filename = str(path.split(track.getURI())[1])
            self.add_data(track_table, _("File:"), filename)

        # Catalog info
        cats, cat_table = self.add_framed_table(_("Catalogs"), True)
        first = True
        for cat in mp.getCatalogs():
            if not first:
                self.add_data(cat_table, "", "")
            first = False
            self.add_data(cat_table, _("Name:"), cat.getIdentifier())
            self.add_data(cat_table, _("Flavor:"), cat.getFlavor())
            self.add_data(cat_table, _("Type:"), cat.getMimeType())
            filename = str(path.split(cat.getURI())[1])
            self.add_data(cat_table, _("File:"), filename)

        #PACKING
        box = gtk.VBox()
        box.pack_start(basic, False, True, int(self.hprop * 10))
        box.pack_start(ops, False, True, int(self.hprop * 10))
        if mp.getSeries():
            box.pack_start(series, False, True, int(self.hprop * 10))
        box.pack_start(tracks, False, True, int(self.hprop * 10))
        box.pack_start(cats, False, True, int(self.hprop * 10))
        external_align = gtk.Alignment(0.5, 0, 0.8, 0.8)
        external_align.add(box)

        self.add(external_align)

        #BUTTONS
        self.buttons = gtk.HButtonBox()
        self.buttons.set_layout(gtk.BUTTONBOX_SPREAD)

        self.add_button(_("Close"), self.close)
        self.add_button(_("Open Folder"), self.openfolder, mp.getURI())
        box.pack_end(self.buttons, False, False, int(self.hprop * 10))
        self.show_all()
コード例 #16
0
	def __init__(self):
		#gtk entry
		self.entry1 = gtk.Entry()
		self.entry2 = gtk.Entry()
		self.entry3 = gtk.Entry()
		self.entry4 = gtk.Entry()
		self.entry5 = gtk.Entry()
		
		#gtk label
		self.out1 = gtk.Label()
		self.out2 = gtk.Label()
		self.out3 = gtk.Label()
		self.out4 = gtk.Label()
		self.out5 = gtk.Label()
		self.out6 = gtk.Label()
		self.out7 = gtk.Label()
		self.out8 = gtk.Label()
		self.out9 = gtk.Label()
		self.out10 = gtk.Label()
		self.out11 = gtk.Label()
		self.out12 = gtk.Label()
		
		labelA = gtk.Label('')
		labelA.set_markup( _('<b>PENDAPATAN</b>'))
		labelB = gtk.Label('')
		labelB.set_markup( _('<b>ZAKAT PENGHASILAN</b>'))
		labelC = gtk.Label('')
		labelC.set_markup( _('<b>ZAKAT SIMPANAN</b>'))
		
		label1 = gtk.Label( _("Pendapatan atau gaji (per bulan)"))
		label2 = gtk.Label( _("Pendapatan lain (per bulan)"))
		label3 = gtk.Label( _("Pendapatan total (per tahun)"))
		label4 = gtk.Label( _("Kebutuhan (per bulan)"))
		label5 = gtk.Label( _("Kebutuhan total (per tahun)"))
		label6 = gtk.Label( _("Sisa pendapatan"))
		
		label7 = gtk.Label( _("Harga beras saat ini (per kg)"))
		label8 = gtk.Label( _("Besarnya nishab"))
		label9 = gtk.Label( _("Wajib zakat penghasilan?"))
		label10 = gtk.Label( _("Besarnya zakat penghasilan yang harus dibayarkan"))
		label11 = gtk.Label( _("Zakat per tahun"))
		label12 = gtk.Label( _("Zakat per bulan"))
		
		label13 = gtk.Label( _("Harga emas saat ini (per gram)"))
		label14 = gtk.Label( _("Besarnya nishab"))
		label15 = gtk.Label( _("Wajib zakat simpanan?"))
		label16 = gtk.Label( _("Besarnya zakat simpanan yang harus dibayarkan"))
		label17 = gtk.Label( _("Zakat per tahun"))
		label18 = gtk.Label( _("Zakat per bulan"))
					
		#gtk button
		button1 = gtk.Button( _("_Ihwal"), stock='gtk-about')
		button2 = gtk.Button( _("_Hitung Zakat"))
		button3 = gtk.Button( _("_Bersihkan"), stock='gtk-clear')
		button4 = gtk.Button( _("_Tutup"), stock='gtk-close')
		
		#vbox
		vbox1 = gtk.VBox(False, 5)
		vbox2 = gtk.VBox(False, 5)
		
		#buttonbox
		buttonbox = gtk.HButtonBox()
		buttonbox.set_spacing(15)
		buttonbox.set_layout(gtk.BUTTONBOX_CENTER)
						
		buttonbox.add(button1)
		buttonbox.add(button2)
		buttonbox.add(button3)
		buttonbox.add(button4)
		
		#image
		pixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/zacalc/image/logo.png")
		image = gtk.Image()
		image.set_from_pixbuf(pixbuf)
		image.show()
		
		#table
		table1 = gtk.Table(1,6,True)
		table2 = gtk.Table(1,6,True)
			
		#frame
		frame = gtk.Frame()
		frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
								
		#align
		align1 = gtk.Alignment(0.5, 0.3, 0, 0)
		align2 = gtk.Alignment(0.5, 0.1, 0, 0)
		align3 = gtk.Alignment(0.5, 0.5, 0, 0)
		
		#layout inserting
		vbox1.add(frame)
		vbox1.add(buttonbox)
		
		frame.add(align1)
		align1.add(table1)
		align3.add(vbox2)
		align2.add(table2)
		
		table1.attach(image,3,6,0,10)
		
		table1.attach(labelA,0,3,0,1)
		
		table1.attach(label1,0,2,1,2)
		table1.attach(label2,0,2,2,3)
		table1.attach(label3,0,2,3,4)
		table1.attach(label4,0,2,4,5)
		table1.attach(label5,0,2,5,6)
		table1.attach(label6,0,2,6,7)
		
		table1.attach(self.entry1,2,3,1,2)
		table1.attach(self.entry2,2,3,2,3)
		table1.attach(self.out1,2,3,3,4)
		table1.attach(self.entry3,2,3,4,5)
		table1.attach(self.out2,2,3,5,6)
		table1.attach(self.out3,2,3,6,7)
		
		table1.attach(labelB,0,3,8,9)
		
		table1.attach(label7,0,2,9,10)
		table1.attach(label8,0,2,10,11)
		table1.attach(label9,0,2,11,12)
		table1.attach(label10,0,3,12,13)
		
		table1.attach(self.entry4,2,3,9,10)
		table1.attach(self.out4,2,3,10,11)
		table1.attach(self.out5,2,3,11,12)
		
		table1.attach(label11,0,2,13,14)
		table1.attach(label12,0,2,14,15)
		
		table1.attach(self.out6,2,3,13,14)
		table1.attach(self.out7,2,3,14,15)
		
		table1.attach(labelC,3,5,8,9)
		
		table1.attach(label13,3,5,9,10)
		table1.attach(label14,3,5,10,11)
		table1.attach(label15,3,5,11,12)
		table1.attach(label16,3,6,12,13)
		
		table1.attach(self.entry5,5,6,9,10)
		table1.attach(self.out8,5,6,10,11)
		table1.attach(self.out9,5,6,11,12)
	
		table1.attach(label17,3,5,13,14)
		table1.attach(label18,3,5,14,15)
		
		table1.attach(self.out10,5,6,13,14)
		table1.attach(self.out11,5,6,14,15)
			
		#property
		frame.set_label('')
						
		self.clear_value(self)

		self.out1.set_alignment(xalign=0.95, yalign=0.5)
		self.out2.set_alignment(xalign=0.95, yalign=0.5)
		self.out3.set_alignment(xalign=0.95, yalign=0.5)
		self.out4.set_alignment(xalign=0.95, yalign=0.5)
		self.out5.set_alignment(xalign=0.05, yalign=0.5)
		self.out6.set_alignment(xalign=0.95, yalign=0.5)
		self.out7.set_alignment(xalign=0.95, yalign=0.5)
		self.out8.set_alignment(xalign=0.95, yalign=0.5)
		self.out9.set_alignment(xalign=0.05, yalign=0.5)
		self.out10.set_alignment(xalign=0.95, yalign=0.5)
		self.out11.set_alignment(xalign=0.95, yalign=0.5)
				
		labelA.set_alignment(xalign=0, yalign=0.5)
		labelB.set_alignment(xalign=0, yalign=0.5)
		labelC.set_alignment(xalign=0, yalign=0.5)
		
		label1.set_alignment(xalign=0, yalign=0.5)
		label2.set_alignment(xalign=0, yalign=0.5)
		label3.set_alignment(xalign=0, yalign=0.5)
		label4.set_alignment(xalign=0, yalign=0.5)
		label5.set_alignment(xalign=0, yalign=0.5)
		label6.set_alignment(xalign=0, yalign=0.5)
		label7.set_alignment(xalign=0, yalign=0.5)
		label8.set_alignment(xalign=0, yalign=0.5)
		label9.set_alignment(xalign=0, yalign=0.5)
		label10.set_alignment(xalign=0, yalign=0.5)
		label11.set_alignment(xalign=0, yalign=0.5)
		label12.set_alignment(xalign=0, yalign=0.5)
		label13.set_alignment(xalign=0, yalign=0.5)
		label14.set_alignment(xalign=0, yalign=0.5)
		label15.set_alignment(xalign=0, yalign=0.5)
		label16.set_alignment(xalign=0, yalign=0.5)
		label17.set_alignment(xalign=-0, yalign=0.5)
		label18.set_alignment(xalign=-0, yalign=0.5)
		image.set_alignment(xalign=0, yalign=0.5)
		
		table1.set_col_spacings(30)			
		align1.set_padding(5, 5, 15, 15)
		table2.set_col_spacings(0)			
		align2.set_padding(0, 0, 0, 0)
		
		#signal
		self.entry1.connect("changed",  self.valid_number)
		self.entry2.connect("changed",  self.valid_number)
		self.entry3.connect("changed",  self.valid_number)
		self.entry4.connect("changed",  self.valid_number)
		self.entry5.connect("changed",  self.valid_number)
		
		button1.connect("clicked",  self.show_about)
		button2.connect("clicked",  self.calculate)
		button3.connect("clicked",  self.clear_value)
		button4.connect("clicked",  gtk.main_quit)
		
		icon_theme = gtk.icon_theme_get_default()
		try:
			self.icon = icon_theme.load_icon("zacalc", 48, 0)
		except Exception, e:
			print "can't load icon", e
コード例 #17
0
    def create_build_gui(self):
        vbox = gtk.VBox(False, 12)
        vbox.set_border_width(6)
        vbox.show()

        hbox = gtk.HBox(False, 12)
        hbox.show()
        vbox.pack_start(hbox, expand=False, fill=False)

        label = gtk.Label("Machine:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.machine_combo = gtk.combo_box_new_text()
        self.machine_combo.show()
        self.machine_combo.set_tooltip_text(
            "Selects the architecture of the target board for which you would like to build an image."
        )
        hbox.pack_start(self.machine_combo,
                        expand=False,
                        fill=False,
                        padding=6)
        label = gtk.Label("Base image:")
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        self.image_combo = gtk.ComboBox()
        self.image_combo.show()
        self.image_combo.set_tooltip_text(
            "Selects the image on which to base the created image")
        image_combo_cell = gtk.CellRendererText()
        self.image_combo.pack_start(image_combo_cell, True)
        self.image_combo.add_attribute(image_combo_cell, 'text',
                                       self.model.COL_NAME)
        hbox.pack_start(self.image_combo, expand=False, fill=False, padding=6)
        self.progress = gtk.ProgressBar()
        self.progress.set_size_request(250, -1)
        hbox.pack_end(self.progress, expand=False, fill=False, padding=6)

        ins = gtk.Notebook()
        vbox.pack_start(ins, expand=True, fill=True)
        ins.set_show_tabs(True)
        label = gtk.Label("Packages")
        label.show()
        ins.append_page(self.pkgsaz(), tab_label=label)
        label = gtk.Label("Package Collections")
        label.show()
        ins.append_page(self.tasks(), tab_label=label)
        ins.set_current_page(0)
        ins.show_all()

        hbox = gtk.HBox(False, 1)
        hbox.show()
        label = gtk.Label("Estimated image contents:")
        self.model.connect("contents-changed", self.update_package_count_cb,
                           label)
        label.set_property("xalign", 0.00)
        label.show()
        hbox.pack_start(label, expand=False, fill=False, padding=6)
        info = gtk.Button("?")
        info.set_tooltip_text("What does this mean?")
        info.show()
        info.connect("clicked", self.info_button_clicked_cb)
        hbox.pack_start(info, expand=False, fill=False, padding=6)
        vbox.pack_start(hbox, expand=False, fill=False, padding=6)
        con = self.contents()
        con.show()
        vbox.pack_start(con, expand=True, fill=True)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(12)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False, fill=False)
        reset = gtk.Button("Reset")
        reset.connect("clicked", self.reset_clicked_cb)
        reset.show()
        bbox.add(reset)
        bake = gtk.Button("Bake")
        bake.connect("clicked", self.bake_clicked_cb)
        bake.show()
        bbox.add(bake)

        return vbox
コード例 #18
0
    def __init__(self):
        # Create and setup a new window
        #  - titlebar, moveable, resizeable...
        #self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        #  - ontop, sticky, un-moveable, un-resizeable...
        self.window = gtk.Window(gtk.WINDOW_POPUP)
        # Window properties
        self.window.set_title(appname)
        self.window.set_border_width(5)
        self.window.set_size_request(310, 222)
        self.window.set_position(gtk.WIN_POS_CENTER)

        # Connect the destroy event to a handler
        self.window.connect("destroy", lambda x: gtk.main_quit())

        # Create a vertical container box with small padding
        self.vbox = gtk.VBox(False, 2)

        # Create an image
        self.image = gtk.Image()
        self.image.set_from_file(appimage)
        # Integrate it into the vbox
        self.vbox.pack_start(self.image)

        # Create a label notice
        self.label = gtk.Label(appname)
        # Integrate it into the vbox
        self.vbox.pack_start(self.label)

        # Create a scrolled window
        self.scrolledwin = gtk.ScrolledWindow()
        self.scrolledwin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
        self.scrolledwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        # Integrate it into the vbox
        #  - child, expand, fill, padding
        self.vbox.pack_start(self.scrolledwin, True, True, 0)

        # Create a TreeView object
        liststore = self.create_listmodel()
        self.treeview = gtk.TreeView(liststore)
        self.treeview.connect("row-activated", self.on_clkactivated)
        # Change the bg color of every 2nd row
        self.treeview.set_rules_hint(True)

        # Add the TreeView to the scrolled window
        self.scrolledwin.add(self.treeview)
        # Create TreeView columns
        self.create_columns(self.treeview)

        # Add the vbox to the main window
        self.window.add(self.vbox)

        # Create a button box
        self.bbox = gtk.HButtonBox()
        self.vbox.pack_start(self.bbox, False, False, 0)
        self.bbox.set_layout(gtk.BUTTONBOX_SPREAD)

        # OK button widget
        button = gtk.Button(stock=gtk.STOCK_OK)
        button.connect("clicked", self.on_btnactivated)
        self.bbox.add(button)

        # Close button widget
        button = gtk.Button(stock=gtk.STOCK_CANCEL)
        button.connect("clicked", lambda w: gtk.main_quit())
        self.bbox.add(button)
        # This is the default button
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()

        # Set window icon
        gtk.window_set_default_icon(self.presentation_select_icon())

        # Draw the presentation manager
        self.window.show_all()
コード例 #19
0
ファイル: screen_container.py プロジェクト: MikeSquall/tryton
    def search_box(self, button):
        def key_press(window, event):
            if event.keyval == gtk.keysyms.Escape:
                button.set_active(False)
                window.hide()

        def search():
            button.set_active(False)
            self.search_window.hide()
            text = ''
            for label, entry in self.search_table.fields:
                if isinstance(entry, gtk.ComboBox):
                    value = quote(entry.get_active_text()) or None
                elif isinstance(entry, (Dates, Selection)):
                    value = entry.get_value()
                else:
                    value = quote(entry.get_text()) or None
                if value is not None:
                    text += quote(label) + ': ' + value + ' '
            self.set_text(text)
            self.do_search()
            # Store text after doing the search
            # because domain parser could simplify the text
            self.last_search_text = self.get_text()

        if not self.search_window:
            self.search_window = gtk.Window()
            self.search_window.set_transient_for(button.get_toplevel())
            self.search_window.set_type_hint(
                gtk.gdk.WINDOW_TYPE_HINT_POPUP_MENU)
            self.search_window.set_destroy_with_parent(True)
            self.search_window.set_title('coog')
            self.search_window.set_icon(TRYTON_ICON)
            self.search_window.set_decorated(False)
            # set_deletable is False on tryton master repo
            # But this is not working on each graphical environnement
            # Further more, setting theses windows deletable does not seems
            # to bring any trouble.
            self.search_window.set_deletable(True)
            self.search_window.connect('delete-event', lambda *a: True)
            self.search_window.connect('key-press-event', key_press)
            vbox = gtk.VBox()
            fields = [
                f for f in self.screen.domain_parser.fields.itervalues()
                if f.get('searchable', True)
            ]
            self.search_table = gtk.Table(rows=len(fields), columns=2)
            self.search_table.set_homogeneous(False)
            self.search_table.set_border_width(5)
            self.search_table.set_row_spacings(2)
            self.search_table.set_col_spacings(2)

            # Fill table with fields
            self.search_table.fields = []
            for i, field in enumerate(fields):
                label = gtk.Label(field['string'])
                label.set_alignment(0.0, 0.0)
                self.search_table.attach(label,
                                         0,
                                         1,
                                         i,
                                         i + 1,
                                         yoptions=gtk.FILL)
                yoptions = False
                if field['type'] == 'boolean':
                    if hasattr(gtk, 'ComboBoxText'):
                        entry = gtk.ComboBoxText()
                    else:
                        entry = gtk.combo_box_new_text()
                    entry.append_text('')
                    selections = (_('True'), _('False'))
                    for selection in selections:
                        entry.append_text(selection)
                elif field['type'] == 'selection':
                    selections = tuple(x[1] for x in field['selection'])
                    entry = Selection(selections)
                    yoptions = gtk.FILL | gtk.EXPAND
                elif field['type'] in ('date', 'datetime', 'time'):
                    date_format = self.screen.context.get('date_format', '%x')
                    if field['type'] == 'date':
                        entry = Dates(date_format)
                    elif field['type'] in ('datetime', 'time'):
                        time_format = PYSONDecoder({}).decode(field['format'])
                        if field['type'] == 'time':
                            entry = Times(time_format)
                        elif field['type'] == 'datetime':
                            entry = DateTimes(date_format, time_format)
                    entry.connect_activate(lambda *a: search())
                else:
                    entry = gtk.Entry()
                    entry.connect('activate', lambda *a: search())
                label.set_mnemonic_widget(entry)
                self.search_table.attach(entry,
                                         1,
                                         2,
                                         i,
                                         i + 1,
                                         yoptions=yoptions)
                self.search_table.fields.append((field['string'], entry))

            scrolled = gtk.ScrolledWindow()
            scrolled.add_with_viewport(self.search_table)
            scrolled.set_shadow_type(gtk.SHADOW_NONE)
            scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
            vbox.pack_start(scrolled, expand=True, fill=True)
            find_button = gtk.Button(_('Find'))
            find_button.connect('clicked', lambda *a: search())
            find_img = gtk.Image()
            find_img.set_from_stock('tryton-find', gtk.ICON_SIZE_SMALL_TOOLBAR)
            find_button.set_image(find_img)
            hbuttonbox = gtk.HButtonBox()
            hbuttonbox.set_spacing(5)
            hbuttonbox.pack_start(find_button)
            hbuttonbox.set_layout(gtk.BUTTONBOX_END)
            vbox.pack_start(hbuttonbox, expand=False, fill=True)
            self.search_window.add(vbox)
            vbox.show_all()

            new_size = map(
                sum,
                zip(self.search_table.size_request(), scrolled.size_request()))
            self.search_window.set_default_size(*new_size)

        parent = button.get_toplevel()
        button_x, button_y = button.translate_coordinates(parent, 0, 0)
        button_allocation = button.get_allocation()

        # Resize the window to not be out of the parent
        width, height = self.search_window.get_default_size()
        allocation = parent.get_allocation()
        delta_width = allocation.width - (button_x + width)
        delta_height = allocation.height - (button_y +
                                            button_allocation.height + height)
        if delta_width < 0:
            width += delta_width
        if delta_height < 0:
            height += delta_height
        self.search_window.resize(width, height)

        # Move the window under the button
        x, y = button.window.get_origin()
        self.search_window.move(
            x + button_allocation.x,
            y + button_allocation.y + button_allocation.height)

        from tryton.gui.main import Main
        page = Main.get_main().get_page()
        if button.get_active():
            if page and self.search_window not in page.dialogs:
                page.dialogs.append(self.search_window)
            self.search_window.show()

            if self.last_search_text.strip() != self.get_text().strip():
                for label, entry in self.search_table.fields:
                    if isinstance(entry, gtk.ComboBox):
                        entry.set_active(-1)
                    elif isinstance(entry, Dates):
                        entry.set_values(None, None)
                    elif isinstance(entry, Selection):
                        entry.treeview.get_selection().unselect_all()
                    else:
                        entry.set_text('')
                if self.search_table.fields:
                    self.search_table.fields[0][1].grab_focus()

        else:
            self.search_window.hide()
            if page and self.search_window in page.dialogs:
                page.dialogs.remove(self.search_window)
コード例 #20
0
ファイル: mirrors.py プロジェクト: pombreda/smart
    def __init__(self):

        self._window = gtk.Window()
        self._window.set_icon(getPixbuf("smart"))
        self._window.set_title(_("New Mirror"))
        self._window.set_modal(True)
        self._window.set_position(gtk.WIN_POS_CENTER)

        #self._window.set_geometry_hints(min_width=600, min_height=400)
        def delete(widget, event):
            gtk.main_quit()
            return True

        self._window.connect("delete-event", delete)

        vbox = gtk.VBox()
        vbox.set_border_width(10)
        vbox.set_spacing(10)
        vbox.show()
        self._window.add(vbox)

        table = gtk.Table()
        table.set_row_spacings(10)
        table.set_col_spacings(10)
        table.show()
        vbox.pack_start(table)

        label = gtk.Label(_("Origin URL:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL)

        self._origin = gtk.Entry()
        self._origin.set_width_chars(40)
        self._origin.show()
        table.attach(self._origin, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.FILL)

        label = gtk.Label(_("Mirror URL:"))
        label.set_alignment(1.0, 0.5)
        label.show()
        table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL)

        self._mirror = gtk.Entry()
        self._mirror.set_width_chars(40)
        self._mirror.show()
        table.attach(self._mirror, 1, 2, 1, 2, gtk.EXPAND | gtk.FILL, gtk.FILL)

        sep = gtk.HSeparator()
        sep.show()
        vbox.pack_start(sep, expand=False)

        bbox = gtk.HButtonBox()
        bbox.set_spacing(10)
        bbox.set_layout(gtk.BUTTONBOX_END)
        bbox.show()
        vbox.pack_start(bbox, expand=False)

        self._okbutton = gtk.Button(stock="gtk-ok")
        self._okbutton.show()

        def clicked(x):
            self._result = True
            gtk.main_quit()

        self._okbutton.connect("clicked", clicked)
        bbox.pack_start(self._okbutton)

        self._cancelbutton = gtk.Button(stock="gtk-cancel")
        self._cancelbutton.show()
        self._cancelbutton.connect("clicked", lambda x: gtk.main_quit())
        bbox.pack_start(self._cancelbutton)
コード例 #21
0
    def __init__(self, session, account):
        '''constructor'''
        gtk.VBox.__init__(self)
        self.set_border_width(2)
        all = gtk.HBox()
        all.set_border_width(2)
        self.first = True

        self.calendars = gtk.VBox()
        self.calendars.set_border_width(2)

        chat_box = gtk.VBox()
        chat_box.set_border_width(2)

        self.session = session
        self.account = account

        if self.session:
            self.contact = self.session.contacts.get(account)

        OutputText = extension.get_default('conversation output')
        self.text = OutputText(session.config)
        self.formatter = e3.common.MessageFormatter(session.contacts.me)

        buttons = gtk.HButtonBox()
        buttons.set_border_width(2)
        buttons.set_layout(gtk.BUTTONBOX_END)
        save = gtk.Button(stock=gtk.STOCK_SAVE)
        refresh = gtk.Button(stock=gtk.STOCK_REFRESH)

        toggle_calendars = gtk.Button(_("Hide calendars"))

        buttons.pack_start(toggle_calendars)
        buttons.pack_start(refresh)
        buttons.pack_start(save)

        self.from_calendar = gtk.Calendar()
        from_year, from_month, from_day = self.from_calendar.get_date()
        from_datetime = datetime.date(from_year, from_month + 1,
                                      from_day) - datetime.timedelta(30)

        self.from_calendar.select_month(from_datetime.month - 1,
                                        from_datetime.year)
        self.from_calendar.select_day(from_datetime.day)
        self.to_calendar = gtk.Calendar()

        save.connect('clicked', self._on_save_clicked)
        refresh.connect('clicked', self._on_refresh_clicked)
        toggle_calendars.connect('clicked', self._on_toggle_calendars)

        self.calendars.pack_start(gtk.Label(_('Chats from')), False)
        self.calendars.pack_start(self.from_calendar, True, True)
        self.calendars.pack_start(gtk.Label(_('Chats to')), False)
        self.calendars.pack_start(self.to_calendar, True, True)

        chat_box.pack_start(self.text, True, True)

        all.pack_start(self.calendars, False)
        all.pack_start(chat_box, True, True)

        self.pack_start(all, True, True)
        self.pack_start(buttons, False)
        self.refresh_history()
コード例 #22
0
ファイル: gtkui.py プロジェクト: bossjones/jhbuild
    def create_ui(self):
        self.set_border_width(5)
        app_vbox = gtk.VBox(spacing=5)

        self.module_hbox = gtk.HBox(spacing=5)
        app_vbox.pack_start(self.module_hbox, fill=False, expand=False)

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % _('Choose Module:'))
        self.module_hbox.pack_start(label, fill=False, expand=False)

        self.module_combo = gtk.ComboBox(self.modules_list_model)
        cell = gtk.CellRendererText()
        self.module_combo.pack_start(cell, True)
        self.module_combo.add_attribute(cell, 'text', 0)
        self.module_combo.changed_signal_id = self.module_combo.connect(
            'changed', self.on_module_selection_changed_cb)

        self.module_combo.set_row_separator_func(lambda x, y: x.get(y, 1)[0])
        self.module_hbox.pack_start(self.module_combo, fill=True)

        separator = gtk.VSeparator()
        self.module_hbox.pack_start(separator, fill=False, expand=False)
        preferences = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        preferences.connect('clicked', self.on_preferences_cb)
        self.module_hbox.pack_start(preferences, fill=False, expand=False)

        self.progressbar = gtk.ProgressBar()
        self.progressbar.set_text(_('Build Progress'))
        app_vbox.pack_start(self.progressbar, fill=False, expand=False)

        expander = gtk.Expander(_('Terminal'))
        expander.set_expanded(False)
        app_vbox.pack_start(expander, fill=False, expand=False)
        sclwin = gtk.ScrolledWindow()
        sclwin.set_size_request(-1, 300)
        sclwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
        expander.add(sclwin)
        if vte:
            self.terminal = vte.Terminal()
            self.terminal.connect('child-exited', self.on_vte_child_exit_cb)
        else:
            os.environ['TERM'] = 'dumb'  # avoid commands printing vt sequences
            self.terminal = gtk.TextView()
            self.terminal.set_size_request(800, -1)
            textbuffer = self.terminal.get_buffer()
            terminal_bold_tag = textbuffer.create_tag('bold')
            terminal_bold_tag.set_property('weight', pango.WEIGHT_BOLD)
            terminal_mono_tag = textbuffer.create_tag('mono')
            terminal_mono_tag.set_property('family', 'Monospace')
            terminal_stdout_tag = textbuffer.create_tag('stdout')
            terminal_stdout_tag.set_property('family', 'Monospace')
            terminal_stderr_tag = textbuffer.create_tag('stderr')
            terminal_stderr_tag.set_property('family', 'Monospace')
            terminal_stderr_tag.set_property('foreground', 'red')
            terminal_stdin_tag = textbuffer.create_tag('stdin')
            terminal_stdin_tag.set_property('family', 'Monospace')
            terminal_stdin_tag.set_property('style', pango.STYLE_ITALIC)
            self.terminal.set_editable(False)
            self.terminal.set_wrap_mode(gtk.WRAP_CHAR)
        sclwin.add(self.terminal)
        self.terminal_sclwin = sclwin

        self.error_hbox = self.create_error_hbox()
        app_vbox.pack_start(self.error_hbox, fill=False, expand=False)

        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_END)
        app_vbox.pack_start(buttonbox, fill=False, expand=False)

        # Translators: This is a button label (to start build)
        self.build_button = gtk.Button(_('Start'))
        self.build_button.connect('clicked', self.on_build_cb)
        buttonbox.add(self.build_button)

        button = gtk.Button(stock=gtk.STOCK_HELP)
        button.connect('clicked', self.on_help_cb)
        buttonbox.add(button)
        buttonbox.set_child_secondary(button, True)

        app_vbox.show_all()
        self.error_hbox.hide()
        self.add(app_vbox)