def add_text(self, data_dict, version): '''data_dict ontains text to be added. Key will be the title Value will be... well, the value :)''' ellipsize=Pango.EllipsizeMode.NONE for element in data_dict.keys(): # Element icon if element == 'processor': _icon = Gtk.image_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'processor_small.png') self.box.pack_start(_icon, False, False, 0) else: _icon = Gtk.Image.new_from_stock(self.icons[element], Gtk.IconSize.MENU) self.box.pack_start(_icon, False, False, 0) # Element label label = Gtk.Label() label.set_markup('<b>' + element.capitalize() + ':</b>') label.set_padding(1, 5) label.set_max_width_chars(len(element) + 1) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) # Element content label = Gtk.Label(label=str(data_dict[element])) label.set_padding(1, 5) label.set_max_width_chars(len(str(data_dict[element]))) label.set_single_line_mode(True) label.set_ellipsize(ellipsize) self.box.pack_start(label, True, True, 1) sep = Gtk.VSeparator() self.box.pack_start(sep, True, True, 1) if version: _icon = Gtk.image_new_from_file(os.path.dirname(__file__) + os.sep + 'data' + os.sep + 'bokken-small.svg') self.pack_start(_icon, False, False, 1) label = Gtk.Label() label.set_markup('<b>Bokken ' + version + '</b> (' + self.uicore.backend.capitalize() + ')') label.set_padding(3, 3) self.pack_end(label, False) self.show_all()
def __init__(self) -> None: """ Set up our window """ self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL) self.window.set_border_width(10) self.window.set_title('Eschalon Map/Character Editor v%s' % version) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) col = Gtk.VBox(homogeneous=False, spacing=10) self.window.add(col) # First our header. We're duplicating some code from basegui with the path # detection, but having an icon makes the dialog look less sparse label = Gtk.Label() label.set_markup( '<big><b>Eschalon Map/Character Editor v%s</b></big>' % version) hbox = Gtk.HBox() if getattr(sys, 'frozen', False): icon_filename = os.path.join(os.path.dirname( sys.executable), 'data', 'eb1_icon_64.png') else: icon_filename = os.path.join(os.path.dirname( __file__), 'data', 'eb1_icon_64.png') hbox.pack_start(Gtk.image_new_from_file(icon_filename), False, False) hbox.pack_start(label, False, False) align = Gtk.Alignment.new(0, 0, 1, 1) align.set_padding(5, 5, 40, 40) align.add(hbox) col.add(align) # Now our table of buttons self.table = Gtk.Table(6, 2) self.cur_row = 0 for i in range(1, 4): self.add_launchers('I' * i, self.char(i), self.map(i)) col.add(self.table) # Close button at the bottom bbox = Gtk.HButtonBox() button = Gtk.Button(stock=Gtk.STOCK_CLOSE) button.connect_object("clicked", Gtk.Widget.hide, self.window) button.connect_object("clicked", Gtk.Widget.destroy, self.window) bbox.add(button) align = Gtk.Alignment.new(1, 0, 0, 1) align.set_padding(5, 5, 5, 5) align.add(bbox) col.add(align) # Show everything self.window.show_all()
def __init__(self, qty, base, filename, parent, all_effects, vol_adj, mute_adj): GObject.GObject.__init__(self) self.base = base self.session_filename = filename hbox = Gtk.HBox() hbox.set_spacing(1) self.add(hbox) vbox = Gtk.VBox() hbox.pack_start(vbox, True, True, 0) self.effects = [] self.all_effects = all_effects count = 0 for row in range(qty): effect = Effect(base + row, self.all_effects, parent) self.effects.append(effect) self.all_effects.append(effect) vbox.pack_start(effect, True, True, 0) count += 1 level_vbox = Gtk.VBox() hbox.pack_start(level_vbox, False, padding=3) vol_image = Gtk.image_new_from_file(FGlobs.pkgdatadir / "volume2.png") vol = Gtk.VScale(vol_adj) vol.set_inverted(True) vol.set_draw_value(False) set_tip(vol, _('Effects volume.')) pb = GdkPixbuf.Pixbuf.new_from_file(FGlobs.pkgdatadir / "headroom.png") mute_image = Gtk.image_new_from_pixbuf(pb) mute = Gtk.VScale(mute_adj) mute.set_inverted(True) mute.set_draw_value(False) set_tip(mute, _('Player headroom that is applied when an effect is playing.')) spc = Gtk.VBox() for widget, expand in zip((vol_image, vol, spc, mute_image, mute), (False, True, False, False, True)): level_vbox.pack_start(widget, expand, padding=2)
def __init__(self, num, others, parent): self.num = num self.others = others self.approot = parent self.pathname = None self.uuid = str(uuid.uuid4()) self._repeat_works = False GObject.GObject.__init__(self) self.set_border_width(2) self.set_spacing(3) label = Gtk.Label(label="%02d" % (num + 1)) self.pack_start(label, False) self.clear = LED["clear"].copy() self.green = LED["green"].copy() self.led = Gtk.Image() self.led.set_from_pixbuf(self.clear) self.pack_start(self.led, False) self.old_ledval = 0 image = Gtk.image_new_from_file(FGlobs.pkgdatadir / "stop.png") image.set_padding(4, 4) self.stop = Gtk.Button() self.stop.set_image(image) self.pack_start(self.stop, False) self.stop.connect("clicked", self._on_stop) set_tip(self.stop, _('Stop')) self.trigger = Gtk.Button() self.trigger.set_size_request(80, -1) self.pack_start(self.trigger, True, True, 0) self.trigger_label = Gtk.Label() self.trigger.add(self.trigger_label) pvbox = Gtk.VBox() self.progress = Gtk.ProgressBar() pvbox.pack_start(self.progress, True, True, 1) self.progress.set_orientation(Gtk.PROGRESS_BOTTOM_TO_TOP) self.progress.set_size_request(5, 0) self.pack_start(pvbox, False) self.trigger.connect("clicked", self._on_trigger) self.trigger.drag_dest_set(Gtk.DestDefaults.ALL, self.dndtargets, Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY) self.trigger.connect("drag-data-received", self._drag_data_received) set_tip(self.trigger, _('Play')) self.repeat = Gtk.ToggleButton() image = Gtk.Image() pb = GdkPixbuf.Pixbuf.new_from_file_at_size(FGlobs.pkgdatadir / "repeat.png", 23, 19) image.set_from_pixbuf(pb) self.repeat.add(image) image.show() self.pack_start(self.repeat, False) set_tip(self.repeat, _('Repeat')) image = Gtk.Image.new_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.MENU) self.config = Gtk.Button() self.config.set_image(image) self.pack_start(self.config, False) self.config.connect("clicked", self._on_config) self.config.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, self.dndsources, Gdk.DragAction.DEFAULT | Gdk.DragAction.COPY) self.config.connect("drag-begin", self._drag_begin) self.config.connect("drag-data-get", self._drag_get_data) self.config.connect("drag-end", self._drag_end) set_tip(self.config, _('Configure')) self.dialog = EffectConfigDialog(self, parent.window) self.dialog.connect("response", self._on_dialog_response) self.dialog.emit("response", Gtk.ResponseType.NO) self.timeout_source_id = None self.interlude = IDJC_Media_Player(None, None, parent) self.effect_length = 0.0 # Create the widget that will be used in the tab self.tabwidget = Gtk.HBox() self.tabwidget.set_spacing(3) sep = Gtk.VSeparator() self.tabwidget.pack_start(sep, True, True, 0) vb = Gtk.VBox() self.tabwidget.pack_start(vb, True, True, 0) hb = Gtk.HBox() hb.set_spacing(3) self.tabeffectname = Gtk.Label() self.tabeffecttime = Gtk.Label() hb.pack_start(self.tabeffectname, True, True, 0) hb.pack_start(self.tabeffecttime, True, True, 0) vb.pack_start(hb, True, True, 0) self.tabeffectprog = Gtk.ProgressBar() self.tabeffectprog.set_size_request(-0, 3) vb.pack_start(self.tabeffectprog, True, True, 0) self.tabwidget.show_all()
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 self.dic = {} # Canvas self._canvas = Gtk.VBox() hbox = Gtk.HBox() self._liststore1 = Gtk.ListStore(str) self.combo1 = Gtk.ComboBox(self._liststore1) cell = Gtk.CellRendererText() self.combo1.pack_start(cell, True) self.combo1.add_attribute(cell, 'markup', 0) self.combo1.connect('changed', self._call) flip_btn = Gtk.Button() flip_btn.connect('clicked', self._flip) flip_btn.add(Gtk.image_new_from_file('icons/flip.svg')) self._liststore2 = Gtk.ListStore(str) self.combo2 = Gtk.ComboBox(self._liststore1) cell = Gtk.CellRendererText() self.combo2.pack_start(cell, True) self.combo2.add_attribute(cell, 'markup', 0) self.combo2.connect('changed', self._call) self.label_box = Gtk.HBox() self.adjustment = Gtk.Adjustment(1.0, 0.0000000001, 10.0 ** 20.0, 0.1, 1.0) self.spin = Gtk.SpinButton(self.adjustment, 0.0, 2) self.label = Gtk.Label() self.label.set_selectable(True) self.label._size = 12 self.label.connect('expose-event', self.resize_label) self.convert_btn = Gtk.Button(_('Convert')) self.convert_btn.connect('clicked', self._call) self._canvas.pack_start(hbox, False, False, 20) hbox.pack_start(self.combo1, False, True, 20) hbox.pack_start(flip_btn, True, False) hbox.pack_end(self.combo2, False, True, 20) spin_box = Gtk.HBox() convert_box = Gtk.HBox() convert_box.pack_start(spin_box, True, False, 0) spin_box.pack_start(self.spin, False, False, 0) self._canvas.pack_start(convert_box, False, False, 5) self._canvas.pack_start(self.label_box, True, False, 0) self.label_box.add(self.label) spin_box.pack_start(self.convert_btn, False, False, 20) self.set_canvas(self._canvas) # Toolbar toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbarbox.toolbar.insert(activity_button, 0) separator = Gtk.SeparatorToolItem() separator.set_expand(False) separator.set_draw(True) toolbarbox.toolbar.insert(separator, -1) # RadioToolButton self._length_btn = RadioToolButton() self._length_btn.connect('clicked', lambda w: self._update_combo(convert.length)) # TRANS: https://en.wikipedia.org/wiki/Length self._length_btn.set_tooltip(_('Length')) self._length_btn.props.icon_name = 'length' self._volume_btn = RadioToolButton() self._volume_btn.connect('clicked', lambda w: self._update_combo(convert.volume)) # TRANS: https://en.wikipedia.org/wiki/Volume self._volume_btn.set_tooltip(_('Volume')) self._volume_btn.props.icon_name = 'volume' self._volume_btn.props.group = self._length_btn self._area_btn = RadioToolButton() self._area_btn.connect('clicked', lambda w: self._update_combo(convert.area)) # TRANS: https://en.wikipedia.org/wiki/Area self._area_btn.set_tooltip(_('Area')) self._area_btn.props.icon_name = 'area' self._area_btn.props.group = self._length_btn self._weight_btn = RadioToolButton() self._weight_btn.connect('clicked', lambda w: self._update_combo(convert.weight)) # TRANS: https://en.wikipedia.org/wiki/Weight self._weight_btn.set_tooltip(_('Weight')) self._weight_btn.props.icon_name = 'weight' self._weight_btn.props.group = self._length_btn self._speed_btn = RadioToolButton() self._speed_btn.connect('clicked', lambda w: self._update_combo(convert.speed)) # TRANS: https://en.wikipedia.org/wiki/Speed self._speed_btn.set_tooltip(_('Speed')) self._speed_btn.props.icon_name = 'speed' self._speed_btn.props.group = self._length_btn self._time_btn = RadioToolButton() self._time_btn.connect('clicked', lambda w: self._update_combo(convert.time)) # TRANS: https://en.wikipedia.org/wiki/Time self._time_btn.set_tooltip(_('Time')) self._time_btn.props.icon_name = 'time' self._time_btn.props.group = self._length_btn self._temp_btn = RadioToolButton() self._temp_btn.connect('clicked', lambda w: self._update_combo(convert.temp)) # TRANS: https://en.wikipedia.org/wiki/Temperature self._temp_btn.set_tooltip(_('Temperature')) self._temp_btn.props.icon_name = 'temp' self._temp_btn.props.group = self._length_btn toolbarbox.toolbar.insert(self._length_btn, -1) toolbarbox.toolbar.insert(self._volume_btn, -1) toolbarbox.toolbar.insert(self._area_btn, -1) toolbarbox.toolbar.insert(self._weight_btn, -1) toolbarbox.toolbar.insert(self._speed_btn, -1) toolbarbox.toolbar.insert(self._time_btn, -1) toolbarbox.toolbar.insert(self._temp_btn, -1) separator = Gtk.SeparatorToolItem() separator.set_expand(True) separator.set_draw(False) toolbarbox.toolbar.insert(separator, -1) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) self._update_combo(convert.length) self.show_all()
def __init__(self, handle): activity.Activity.__init__(self, handle, True) self.max_participants = 1 self.dic = {} # Canvas self._canvas = Gtk.VBox() hbox = Gtk.HBox() self._liststore1 = Gtk.ListStore(str) self.combo1 = Gtk.ComboBox(self._liststore1) cell = Gtk.CellRendererText() self.combo1.pack_start(cell, True) self.combo1.add_attribute(cell, 'markup', 0) self.combo1.connect('changed', self._call) flip_btn = Gtk.Button() flip_btn.connect('clicked', self._flip) flip_btn.add(Gtk.image_new_from_file('icons/flip.svg')) self._liststore2 = Gtk.ListStore(str) self.combo2 = Gtk.ComboBox(self._liststore1) cell = Gtk.CellRendererText() self.combo2.pack_start(cell, True) self.combo2.add_attribute(cell, 'markup', 0) self.combo2.connect('changed', self._call) self.label_box = Gtk.HBox() self.adjustment = Gtk.Adjustment(1.0, 0.0000000001, 10.0 ** 20.0, 0.1, 1.0) self.spin = Gtk.SpinButton(self.adjustment, 0.0, 2) self.label = Gtk.Label() self.label.set_selectable(True) self.label._size = 12 self.label.connect('expose-event', self.resize_label) self.convert_btn = Gtk.Button(_('Convert')) self.convert_btn.connect('clicked', self._call) self._canvas.pack_start(hbox, False, False, 20) hbox.pack_start(self.combo1, False, True, 20) hbox.pack_start(flip_btn, True, False) hbox.pack_end(self.combo2, False, True, 20) spin_box = Gtk.HBox() convert_box = Gtk.HBox() convert_box.pack_start(spin_box, True, False, 0) spin_box.pack_start(self.spin, False, False, 0) self._canvas.pack_start(convert_box, False, False, 5) self._canvas.pack_start(self.label_box, True, False, 0) self.label_box.add(self.label) spin_box.pack_start(self.convert_btn, False, False, 20) self.set_canvas(self._canvas) # Toolbar toolbarbox = ToolbarBox() activity_button = ActivityToolbarButton(self) toolbarbox.toolbar.insert(activity_button, 0) separator = Gtk.SeparatorToolItem() separator.set_expand(False) separator.set_draw(True) toolbarbox.toolbar.insert(separator, -1) # RadioToolButton self._length_btn = RadioToolButton() self._length_btn.connect('clicked', lambda w: self._update_combo(convert.length)) self._length_btn.set_tooltip(_('Length')) self._length_btn.props.icon_name = 'length' self._volume_btn = RadioToolButton() self._volume_btn.connect('clicked', lambda w: self._update_combo(convert.volume)) self._volume_btn.set_tooltip(_('Volume')) self._volume_btn.props.icon_name = 'volume' self._volume_btn.props.group = self._length_btn self._area_btn = RadioToolButton() self._area_btn.connect('clicked', lambda w: self._update_combo(convert.area)) self._area_btn.set_tooltip(_('Area')) self._area_btn.props.icon_name = 'area' self._area_btn.props.group = self._length_btn self._weight_btn = RadioToolButton() self._weight_btn.connect('clicked', lambda w: self._update_combo(convert.weight)) self._weight_btn.set_tooltip(_('Weight')) self._weight_btn.props.icon_name = 'weight' self._weight_btn.props.group = self._length_btn self._speed_btn = RadioToolButton() self._speed_btn.connect('clicked', lambda w: self._update_combo(convert.speed)) self._speed_btn.set_tooltip(_('Speed')) self._speed_btn.props.icon_name = 'speed' self._speed_btn.props.group = self._length_btn self._time_btn = RadioToolButton() self._time_btn.connect('clicked', lambda w: self._update_combo(convert.time)) self._time_btn.set_tooltip(_('Time')) self._time_btn.props.icon_name = 'time' self._time_btn.props.group = self._length_btn self._temp_btn = RadioToolButton() self._temp_btn.connect('clicked', lambda w: self._update_combo(convert.temp)) self._temp_btn.set_tooltip(_('Temperature')) self._temp_btn.props.icon_name = 'temp' self._temp_btn.props.group = self._length_btn toolbarbox.toolbar.insert(self._length_btn, -1) toolbarbox.toolbar.insert(self._volume_btn, -1) toolbarbox.toolbar.insert(self._area_btn, -1) toolbarbox.toolbar.insert(self._weight_btn, -1) toolbarbox.toolbar.insert(self._speed_btn, -1) toolbarbox.toolbar.insert(self._time_btn, -1) toolbarbox.toolbar.insert(self._temp_btn, -1) separator = Gtk.SeparatorToolItem() separator.set_expand(True) separator.set_draw(False) toolbarbox.toolbar.insert(separator, -1) stopbtn = StopButton(self) toolbarbox.toolbar.insert(stopbtn, -1) self.set_toolbar_box(toolbarbox) self._update_combo(convert.length) self.show_all()