def __init__(self): #layout self.contenitore_gen = gtk.VBox() box_gen = gtk.VBox() box_dim_col = gtk.VBox() self.contenitore_gen.pack_start(box_gen, False, False, 0) box_gen.pack_start(box_dim_col, True, True, 1) #window self.win = gtk.Window(gtk.WINDOW_TOPLEVEL) self.win.connect("destroy", self.destroy) self.win.set_title("Texture Generator 1.1") self.win.set_position(gtk.WIN_POS_CENTER) self.win.set_default_size(400, 400) self.win.set_resizable(False) self.win.set_deletable(False) self.win.set_border_width(2) self.icon = self.win.render_icon(gtk.STOCK_NO, gtk.ICON_SIZE_BUTTON) self.win.set_icon(self.icon) self.label = gtk.Label( "Select the formats you would like to create:\n") self.win.add(self.contenitore_gen) #tab dimension and color box_dimxy = gtk.HBox() #texture width box_dimx = gtk.HBox() label_dimx = gtk.Label("Texture Width:") label_dimx.set_size_request(120, 40) start_dim_x = gtk.Adjustment(1200, 0, 100000, 1, 10, 0) self.texw = gtk.SpinButton(start_dim_x, 1.0, 0) box_dimx.pack_start(label_dimx, True, True, 1) box_dimx.pack_start(self.texw, True, True, 1) #texture height box_dimy = gtk.HBox() label_dimy = gtk.Label("Texture Height:") label_dimy.set_size_request(120, 40) start_dim_y = gtk.Adjustment(1200, 0, 100000, 1, 10, 0) self.texh = gtk.SpinButton(start_dim_y, 1.0, 0) box_dimx.pack_start(label_dimy, True, True, 1) box_dimx.pack_start(self.texh, True, True, 1) box_dimxy.pack_start(box_dimx, True, True, 1) box_dimxy.pack_start(box_dimy, True, True, 1) box_dim_col.pack_start(box_dimxy, True, True, 1) box_strip_xy = gtk.HBox() #strip width box_stripx = gtk.HBox() label_stripx = gtk.Label("Strip Width:") label_stripx.set_size_request(120, 40) start_strip_x = gtk.Adjustment(300, 0, 100000, 1, 10, 0) self.stripw = gtk.SpinButton(start_strip_x, 1.0, 0) self.stripw.connect("value-changed", self.Set_Basket_Width) box_stripx.pack_start(label_stripx, True, True, 1) box_stripx.pack_start(self.stripw, True, True, 1) #strip height box_stripy = gtk.HBox() label_stripy = gtk.Label("Strip Height:") label_stripy.set_size_request(120, 40) start_strip_y = gtk.Adjustment(150, 0, 100000, 1, 10, 0) self.striph = gtk.SpinButton(start_strip_y, 1.0, 0) self.striph.connect("value-changed", self.Set_Basket_Height) box_stripx.pack_start(label_stripy, True, True, 1) box_stripx.pack_start(self.striph, True, True, 1) box_strip_xy.pack_start(box_stripx, True, True, 1) box_strip_xy.pack_start(box_stripy, True, True, 1) box_dim_col.pack_start(box_strip_xy, True, True, 1) #space box_gen.pack_start(gtk.Label(""), True, True, 1) #choise strip box_strip = gtk.HBox() self.gen_strip = gtk.RadioButton(None, "Generate Strip") self.gen_strip.connect("toggled", self.Generate_Load, "G") self.gen_strip.set_active(True) self.load_strip = gtk.RadioButton(self.gen_strip, "Load Strip") self.load_strip.connect("toggled", self.Generate_Load, "L") box_strip.pack_start(self.gen_strip, True, True, 0) box_strip.pack_start(self.load_strip, True, True, 0) box_gen.pack_start(box_strip, True, True, 0) #space box_gen.pack_start(gtk.Label(""), True, True, 1) box_gen_load = gtk.HBox() box_cstrip = gtk.VBox() #choose type strip box_tstrip = gtk.HBox() self.wood_strip = gtk.RadioButton(None, "Wood") self.wood_strip.set_active(True) self.brick_strip = gtk.RadioButton(self.wood_strip, "Brick") self.tile_strip = gtk.RadioButton(self.wood_strip, "Tile") self.wood_strip.connect("toggled", self.Set_Texture, 0) self.brick_strip.connect("toggled", self.Set_Texture, 1) self.tile_strip.connect("toggled", self.Set_Texture, 2) box_tstrip.pack_start(self.wood_strip, True, True, 0) box_tstrip.pack_start(self.brick_strip, True, True, 0) box_tstrip.pack_start(self.tile_strip, True, True, 0) box_cstrip.pack_start(box_tstrip, True, True, 0) box_gen_load.pack_start(box_cstrip, True, True, 0) box_gen.pack_start(box_gen_load, True, True, 0) #tile_effect self.tile_effect = gtk.CheckButton("Effect color tile") self.tile_effect.set_size_request(20, 20) self.tile_effect.set_active(True) box_cstrip.pack_start(self.tile_effect, True, True, 0) #color label_color = gtk.Label("Choose color:") self.color = gtk.ColorButton(color=gtk.gdk.Color(0, 0, 0)) self.color.set_size_request(100, 35) box_cstrip.pack_start(self.color, True, False, 1) #space box_gen_load.pack_start(gtk.Label(""), True, True, 2) #choose laying box_laying = gtk.HBox() box_laying2 = gtk.HBox() pose_l = gtk.Label("Laying tipe: ") pose_l.set_size_request(120, 40) pose_v = gtk.Label("") pose_v.set_size_request(120, 40) self.brick_b = gtk.RadioButton(None, "Brick Bond") self.brick_b.connect("toggled", self.Set_Laying, 0) self.brick_b.set_active(True) self.set_tooltip(self.brick_b, "_ _ _ _ _\n _ _ _ _\n_ _ _ _ _\n _ _ _ _") self.brick_rx = gtk.RadioButton(self.brick_b, "Brick RandomX") self.brick_rx.connect("toggled", self.Set_Laying, 1) self.set_tooltip( self.brick_rx, "_ _ _ _ _\n _ _ _ _\n_ _ _ _ _\n _ _ _ _\nRandom X position") self.brick_rxy = gtk.RadioButton(self.brick_b, "Brick RandomXY") self.brick_rxy.connect("toggled", self.Set_Laying, 2) self.set_tooltip( self.brick_rxy, "_ _ _ _ _\n _ _ _ _\n_ _ _ _ _\n _ _ _ _\nRandom X position\nRandom Y height" ) self.basket = gtk.RadioButton(self.brick_b, "Basket 5/1") self.basket.connect("toggled", self.Set_Laying, 3) self.set_tooltip( self.basket, "_____|||||\n_____|||||\n_____|||||\n_____|||||\n_____|||||\n|||||_____\n|||||_____\n|||||_____\n|||||_____\n|||||_____" ) self.herringbone = gtk.RadioButton(self.brick_b, "Herringbone") self.herringbone.connect("toggled", self.Set_Laying, 4) her = "/////\n" + "\\" + "\\" + "\\" + "\\" + "\\" self.set_tooltip(self.herringbone, her) self.tile = gtk.RadioButton(self.brick_b, "Tile") self.tile.connect("toggled", self.Set_Laying, 5) self.set_tooltip(self.tile, "_ _ _ _ _\n_ _ _ _ _\n_ _ _ _ _\n_ _ _ _ _") box_laying.pack_start(pose_l, True, True, 0) box_laying.pack_start(self.brick_b, True, True, 0) box_laying.pack_start(self.brick_rx, True, True, 0) box_laying.pack_start(self.brick_rxy, True, True, 0) box_laying2.pack_start(pose_v, False, False, 0) box_laying2.pack_start(self.basket, False, False, 0) box_laying2.pack_start(self.herringbone, False, False, 0) box_laying2.pack_start(self.tile, False, False, 5) box_gen.pack_start(box_laying, True, True, 0) box_gen.pack_start(box_laying2, True, True, 0) #space box_gen_load.pack_start(gtk.Label(""), True, True, 2) box_vload = gtk.VBox() #load dir strip self.load_dir = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_OPEN, gtk.ICON_SIZE_SMALL_TOOLBAR) self.load_dir.set_image(image) self.load_dir.set_label("Load strip folder") self.load_dir.set_size_request(100, 35) self.load_dir.connect("clicked", self.Load_Strip) #randomize self.randomize = gtk.CheckButton("Randomize map") self.randomize.set_size_request(20, 20) box_vload.pack_start(self.randomize, True, False, 1) box_vload.pack_start(self.load_dir, True, False, 1) box_gen_load.pack_start(box_vload, True, True, 0) #space box_gen_load.pack_start(gtk.Label(""), True, True, 0) #merge self.merge = gtk.CheckButton("Merge layers") self.merge.set_size_request(20, 20) self.merge.set_active(True) box_gen.pack_start(self.merge, True, True, 3) #bump self.bump = gtk.CheckButton("Create bump map") self.bump.set_size_request(20, 20) box_gen.pack_start(self.bump, True, True, 3) #progress bar self.pbar = gtk.ProgressBar() self.pbar.set_text("0 %") box_gen.pack_start(self.pbar, True, True, 5) #control button box_btn = gtk.HBox() self.exit = gtk.Button() img_exit = gtk.Image() img_exit.set_from_stock(gtk.STOCK_QUIT, gtk.ICON_SIZE_SMALL_TOOLBAR) self.exit.set_image(img_exit) self.exit.set_label("Quit") self.exit.set_size_request(100, 35) self.exit.connect("clicked", self.destroy) self.exe = gtk.Button() img_exe = gtk.Image() img_exe.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_SMALL_TOOLBAR) self.exe.set_image(img_exe) self.exe.set_label("Run") self.exe.set_size_request(100, 35) self.exe.connect("clicked", self.Generate_Texture) box_btn.pack_start(self.exit, True, True, 1) box_btn.pack_start(self.exe, True, True, 1) box_gen.pack_start(box_btn, True, True, 1) self.Generate_Load(self, "G") self.Set_Texture(self, 0) self.win.show_all()
def show_options(self, origin, table=None): """Creates the text and menu widget for every possible value on a given track""" if table == None: table = self.table model = origin.get_model() for child in table.get_children(): if type(child) is gtk.Label and child.get_text() == "Type": pass elif child == origin: pass else: table.remove(child) table.resize(1, 1) klass = model[origin.get_active()][1] options = klass.gc_parameters row = 2 for name in klass.order: values = options[name] #for name,values in options.iteritems(): kind = values["type"] label = gtk.Label(name.title()) label.set_width_chars(20) label.set_alignment(0.0, 0.5) table.attach(label, 0, 1, row, row + 1, False, False, 0, 0) if kind in ["text", "device", "caps"]: widget = gtk.Entry() widget.set_text(values['default']) widget.set_alignment(0.0) elif kind == "flavor": store = gtk.ListStore(str) widget = gtk.ComboBox(store) for option in FLAVORS: store.append([option]) cell = gtk.CellRendererText() widget.pack_start(cell, True) widget.add_attribute(cell, 'text', 0) widget.set_active(FLAVORS.index(values['default'])) elif kind == "integer": adjust = gtk.Adjustment(values["default"], values["range"][0], values["range"][1], 1, 1) widget = gtk.SpinButton(adjust, 1.0, 0) widget.set_alignment(0.0) elif kind == "float": adjust = gtk.Adjustment(values["default"], values["range"][0], values["range"][1], 0.1, 1) widget = gtk.SpinButton(adjust, 0.1, 1) widget.set_alignment(0.0) elif kind == "boolean": widget = gtk.CheckButton("Active") if values['default'] in [ "False", "false", "no", "No", ]: widget.set_mode(False) else: widget.set_mode(True) widget.set_alignment(0.0, 0.5) elif kind == "select": store = gtk.ListStore(str) widget = gtk.ComboBox(store) for value in values['options']: store.append([value]) cell = gtk.CellRendererText() widget.pack_start(cell, True) widget.add_attribute(cell, 'text', 0) widget.set_active(values['options'].index(values['default'])) widget.set_name(name) if kind not in ['integer', 'float']: table.attach(widget, 1, 2, row, row + 1, gtk.FILL, False, 0, 0) else: table.attach(widget, 1, 2, row, row + 1, False, False, 0, 0) label.show() widget.show() row += 1
self.window.invalidate_rect(rect, True) self.window.process_updates(True) def update(view): #return view.zoom_out() angle = 90 * random.randint(0, 4) view.set_angle(angle) return True if __name__ == '__main__': window = gtk.Window() vadj = gtk.Adjustment() hadj = gtk.Adjustment() sw = gtk.ScrolledWindow(hadj, vadj) view = ImageViewer() view.set_file_location(sys.argv[1]) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add_with_viewport(view) window.add(sw) window.set_size_request(800, 600) window.show_all()
def __init__(self, default=0, bounds=(0, 100, 5)): step = bounds[2] self.adj = gtk.Adjustment(default, bounds[0], bounds[1], step, 10 * step, 0) gtk.SpinButton.__init__(self, self.adj, step, precision(step))
def _create_dialog(self, config): skip = gtk.combo_box_new_text() for text in config.get_frameskip_names(): skip.append_text(text) skip.set_active(config.get_frameskip()) skip.set_tooltip_text("Set how many frames are skipped") maxw, maxh = config.get_max_size() maxadjw = gtk.Adjustment(maxw, 320, 1280, 8, 40) maxadjh = gtk.Adjustment(maxh, 200, 960, 8, 40) scalew = gtk.HScale(maxadjw) scaleh = gtk.HScale(maxadjh) scalew.set_digits(0) scaleh.set_digits(0) scalew.set_tooltip_text("Preferred/maximum zoomed width") scaleh.set_tooltip_text("Preferred/maximum zoomed height") desktop = gtk.CheckButton("Keep desktop resolution") desktop.set_active(config.get_desktop()) desktop.set_tooltip_text( "Whether to keep desktop resolution in fullscreen and (try to) scale Atari screen by an integer factor instead" ) borders = gtk.CheckButton("ST/STE overscan borders") borders.set_active(config.get_borders()) borders.set_tooltip_text( "Whether to show overscan borders in ST/STE low/mid-rez. Visible border area is affected by max. zoom size" ) statusbar = gtk.CheckButton("Show statusbar") statusbar.set_active(config.get_statusbar()) statusbar.set_tooltip_text( "Whether to show statusbar with floppy leds etc") led = gtk.CheckButton("Show overlay led") led.set_active(config.get_led()) led.set_tooltip_text( "Whether to show overlay drive led when statusbar isn't visible") crop = gtk.CheckButton("Remove statusbar from screen capture") crop.set_active(config.get_crop()) crop.set_tooltip_text( "Whether to crop statusbar from screenshots and video recordings") dialog = gtk.Dialog("Display settings", self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_APPLY, gtk.RESPONSE_APPLY, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.vbox.add(gtk.Label("Frameskip:")) dialog.vbox.add(skip) dialog.vbox.add(gtk.Label("Max zoomed size:")) dialog.vbox.add(scalew) dialog.vbox.add(scaleh) dialog.vbox.add(desktop) dialog.vbox.add(borders) dialog.vbox.add(statusbar) dialog.vbox.add(led) dialog.vbox.add(crop) dialog.vbox.show_all() self.dialog = dialog self.skip = skip self.maxw = maxadjw self.maxh = maxadjh self.desktop = desktop self.borders = borders self.statusbar = statusbar self.led = led self.crop = crop
def _create_dialog(self, config): skip = gtk.combo_box_new_text() for text in config.get_frameskip_names(): skip.append_text(text) skip.set_active(config.get_frameskip()) skip.set_tooltip_text("Set how many frames are skipped to speed up emulation") slow = gtk.combo_box_new_text() for text in config.get_slowdown_names(): slow.append_text(text) slow.set_active(0) slow.set_tooltip_text("VBL wait multiplier to slow down emulation. Breaks sound and large enough slowdown causes mouse clicks not to work.") maxw, maxh = config.get_max_size() topw, toph = config.get_desktop_size() maxadjw = gtk.Adjustment(maxw, 320, topw, 8, 40) maxadjh = gtk.Adjustment(maxh, 200, toph, 8, 40) scalew = gtk.HScale(maxadjw) scaleh = gtk.HScale(maxadjh) scalew.set_digits(0) scaleh.set_digits(0) scalew.set_tooltip_text("Preferred/maximum zoomed width") scaleh.set_tooltip_text("Preferred/maximum zoomed height") force_max = gtk.CheckButton("Force max resolution (Falcon)") force_max.set_active(config.get_force_max()) force_max.set_tooltip_text("Whether to force maximum resolution to help recording videos of demos which do resolution changes") desktop = gtk.CheckButton("Keep desktop resolution (Falcon/TT)") desktop.set_active(config.get_desktop()) desktop.set_tooltip_text("Whether to keep screen resolution in fullscreen and (try to) scale Atari screen by an integer factor instead") desktop_st = gtk.CheckButton("Keep desktop resolution (ST/STE)") desktop_st.set_active(config.get_desktop_st()) desktop_st.set_tooltip_text("Whether to keep screen resolution in fullscreen to avoid potential sound skips + delay (NO SCALING)") borders = gtk.CheckButton("Atari screen borders") borders.set_active(config.get_borders()) borders.set_tooltip_text("Whether to show overscan borders in ST/STE low/mid-rez or in Falcon color resolutions. Visible border area is affected by max. zoom size") statusbar = gtk.CheckButton("Show statusbar") statusbar.set_active(config.get_statusbar()) statusbar.set_tooltip_text("Whether to show statusbar with floppy leds etc") led = gtk.CheckButton("Show overlay led") led.set_active(config.get_led()) led.set_tooltip_text("Whether to show overlay drive led when statusbar isn't visible") crop = gtk.CheckButton("Remove statusbar from screen capture") crop.set_active(config.get_crop()) crop.set_tooltip_text("Whether to crop statusbar from screenshots and video recordings") dialog = gtk.Dialog("Display settings", self.parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_APPLY, gtk.RESPONSE_APPLY, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) dialog.vbox.add(gtk.Label("Max zoomed size:")) dialog.vbox.add(scalew) dialog.vbox.add(scaleh) dialog.vbox.add(force_max) dialog.vbox.add(desktop) dialog.vbox.add(desktop_st) dialog.vbox.add(borders) dialog.vbox.add(gtk.Label("Frameskip:")) dialog.vbox.add(skip) dialog.vbox.add(gtk.Label("Slowdown:")) dialog.vbox.add(slow) dialog.vbox.add(statusbar) dialog.vbox.add(led) dialog.vbox.add(crop) dialog.vbox.show_all() self.dialog = dialog self.skip = skip self.slow = slow self.maxw = maxadjw self.maxh = maxadjh self.force_max = force_max self.desktop = desktop self.desktop_st = desktop_st self.borders = borders self.statusbar = statusbar self.led = led self.crop = crop
def __init__(self, w, h, Widget): self.window = gtk.Window() self.window.resize(w, h) self.window.connect("delete-event", gtk.main_quit) self.menu_bar = gtk.MenuBar() self.file_menu = gtk.Menu() self.file_item = gtk.MenuItem("File") self.file_item.set_submenu(self.file_menu) self.menu_bar.append(self.file_item) self.open_project_item = gtk.MenuItem("Open project ...") self.save_project_item = gtk.MenuItem("Save project ...") sep_export_import = gtk.SeparatorMenuItem() self.import_item = gtk.MenuItem("Import tileset ...") self.export_item = gtk.MenuItem("Export ...") self.quit_item = gtk.MenuItem("Quit") sep_quit = gtk.SeparatorMenuItem() self.file_menu.append(self.open_project_item) self.file_menu.append(self.save_project_item) self.file_menu.append(sep_export_import) self.file_menu.append(self.import_item) self.file_menu.append(self.export_item) self.file_menu.append(sep_quit) self.file_menu.append(self.quit_item) self.import_item.connect( "activate", lambda *args: ep.push_event(EVEnum.import_click, args)) self.export_item.connect( "activate", lambda *args: ep.push_event(EVEnum.export_click, args)) self.open_project_item.connect( "activate", lambda *args: ep.push_event(EVEnum.load_project_click, args)) self.save_project_item.connect( "activate", lambda *args: ep.push_event(EVEnum.save_project_click, args)) self.quit_item.connect( "activate", lambda *args: ep.push_event(EVEnum.quit_click, args)) self.window_vbox = gtk.VBox(homogeneous=False, spacing=0) self.window_vbox.pack_start(self.menu_bar, expand=False, fill=False, padding=0) self.window.add(self.window_vbox) self.widget = Widget() self.widget.connect("button_press_event", self.widget.button_press_event) self.widget.connect("button_release_event", self.widget.button_release_event) self.widget.connect("motion_notify_event", self.widget.motion_notify_event) self.widget.connect("scroll_event", self.widget.scroll_event) self.window.connect("key_press_event", self.widget.key_press_event) self.window.connect("key_release_event", self.widget.key_release_event) self.window.set_events(gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK) self.widget.set_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.POINTER_MOTION_MASK) self.__mk_left_vbox() self.hbox = gtk.HBox(homogeneous=False, spacing=0) self.hbox.pack_start(self.left_vbox, expand=False, fill=False, padding=0) self.widget_hbox = gtk.HBox(homogeneous=False, spacing=0) self.widget_vbox = gtk.VBox(homogeneous=False, spacing=0) self.widget_hscroll = gtk.HScrollbar( gtk.Adjustment(0.0, 0.0, 0.0, 10.0, 100.0, 1.0)) self.widget_hscroll.connect( "value-changed", lambda *args: ep.push_event(EVEnum.hscroll, (args))) self.widget_vscroll = gtk.VScrollbar( gtk.Adjustment(0.0, 0.0, 0.0, 10.0, 100.0, 1.0)) self.widget_vscroll.connect( "value-changed", lambda *args: ep.push_event(EVEnum.vscroll, (args))) self.widget_hbox.pack_start(self.widget, expand=True, fill=True, padding=0) self.widget_hbox.pack_start(self.widget_vscroll, expand=False, fill=False, padding=0) self.widget_vbox.pack_start(self.widget_hbox, expand=True, fill=True) self.widget_vbox.pack_start(self.widget_hscroll, expand=False, fill=False, padding=0) self.hbox.pack_start(self.widget_vbox, expand=True, fill=True, padding=0) self.status_hbox = gtk.HBox(homogeneous=False, spacing=5) self.cursor_pos_label = gtk.Label("") self.scale_label = gtk.Label("") self.mode_label = gtk.Label("") self.status_hbox.pack_start(self.cursor_pos_label, expand=False, fill=False) self.status_hbox.pack_start(self.scale_label, expand=False, fill=False) self.status_hbox.pack_start(self.mode_label, expand=False, fill=False) self.widget_vbox.pack_start(self.status_hbox, expand=False, fill=False) self.__mk_right_vbox() self.hbox.pack_start(self.right_vbox, expand=False, fill=False, padding=0) gobject.timeout_add(30, self.widget.periodic) self.window_vbox.pack_start(self.hbox, expand=True, fill=True, padding=0)
def __init__(self, user, playername, parent_window): gtk.Dialog.__init__(self, "Form New Game - %s" % playername, parent_window) self.game_name = None self.min_players = None self.max_players = None self.user = user self.playername = playername self.parent_window = parent_window self.set_icon(icon.pixbuf) self.set_transient_for(parent_window) self.set_destroy_with_parent(True) hbox1 = gtk.HBox() self.vbox.pack_start(hbox1) label1 = gtk.Label("Name of game") hbox1.pack_start(label1, expand=False) self.name_entry = gtk.Entry(max=40) self.name_entry.set_width_chars(40) hbox1.pack_start(self.name_entry, expand=False) min_adjustment = gtk.Adjustment(2, 2, 6, 1, 0, 0) max_adjustment = gtk.Adjustment(6, 2, 6, 1, 0, 0) ai_time_limit_adjustment = gtk.Adjustment(config.DEFAULT_AI_TIME_LIMIT, 1, 99, 1, 0, 0) player_time_limit_adjustment = gtk.Adjustment( config.DEFAULT_PLAYER_TIME_LIMIT, 1, 999, 1, 100, 0) hbox2 = gtk.HBox() self.vbox.pack_start(hbox2) label2 = gtk.Label("Min players") hbox2.pack_start(label2, expand=False) self.min_players_spin = gtk.SpinButton(adjustment=min_adjustment, climb_rate=1, digits=0) self.min_players_spin.set_numeric(True) self.min_players_spin.set_update_policy(gtk.UPDATE_IF_VALID) self.min_players_spin.set_value(2) hbox2.pack_start(self.min_players_spin, expand=False) label3 = gtk.Label("Max players") hbox2.pack_start(label3, expand=False) self.max_players_spin = gtk.SpinButton(adjustment=max_adjustment, climb_rate=1, digits=0) self.max_players_spin.set_numeric(True) self.max_players_spin.set_update_policy(gtk.UPDATE_IF_VALID) self.max_players_spin.set_value(6) hbox2.pack_start(self.max_players_spin, expand=False) label4 = gtk.Label("AI time limit") hbox2.pack_start(label4, expand=False) self.ai_time_limit_spin = gtk.SpinButton( adjustment=ai_time_limit_adjustment, climb_rate=1, digits=0) self.ai_time_limit_spin.set_numeric(True) self.ai_time_limit_spin.set_update_policy(gtk.UPDATE_IF_VALID) hbox2.pack_start(self.ai_time_limit_spin, expand=False) label5 = gtk.Label("Player time limit") hbox2.pack_start(label5, expand=False) self.player_time_limit_spin = gtk.SpinButton( adjustment=player_time_limit_adjustment, climb_rate=1, digits=0) self.player_time_limit_spin.set_numeric(True) self.player_time_limit_spin.set_update_policy(gtk.UPDATE_IF_VALID) hbox2.pack_start(self.player_time_limit_spin, expand=False) self.cancel_button = self.add_button("gtk-cancel", gtk.RESPONSE_CANCEL) self.cancel_button.connect("button-press-event", self.cancel) self.ok_button = self.add_button("gtk-ok", gtk.RESPONSE_OK) self.ok_button.connect("button-press-event", self.ok) self.show_all()
def SETUP_SPINBUTTON (self, spinbutton, config): """ Function doc """ adjustment = gtk.Adjustment(config[0],config[1],config[2],config[3],config[4],config[5]) SpinButton = self.builder.get_object(spinbutton) SpinButton.set_adjustment(adjustment) SpinButton.update()
def create_window(self): listener = self._this() self.level_listener_id = self.corefader.addLevelListener(listener) self.source_listener_id = self.corefader.addSourceListener(listener) self.run_listener_id = self.corefader.addRunListener(listener) self.stop_listener_id = self.corefader.addStopListener(listener) self.complete_listener_id = self.corefader.addCompleteListener( listener) gdk.threads_enter() try: wTree = glade.XML("gtklb.glade", "fader") dic = { "on_run_clicked": self.run_clicked, "on_stop_clicked": self.stop_clicked, "on_clear_clicked": self.clear_clicked, "on_load_clicked": self.load_clicked } wTree.signal_autoconnect(dic) w = wTree.get_widget("fader") w.set_title("Crossfader %s" % self.name) w.connect('destroy', self.window_destroyed) t = wTree.get_widget("topLabel") b = wTree.get_widget("bottomLabel") t.set_text("Up Cue: ---") b.set_text("Down Cue: ---") self.up_label = t self.down_label = b t = wTree.get_widget("topCueLabel") b = wTree.get_widget("bottomCueLabel") t.set_text("Up Cue") b.set_text("Down Cue") t = wTree.get_widget("topTimeLabel") b = wTree.get_widget("bottomTimeLabel") t.set_text("Up Time") b.set_text("Down Time") self.fromSpin = wTree.get_widget("fromSpin") self.toSpin = wTree.get_widget("toSpin") self.upTimeSpin = wTree.get_widget("topTimeSpin") self.downTimeSpin = wTree.get_widget("bottomTimeSpin") r = wTree.get_widget("run") s = wTree.get_widget("stop") if (self.isRunning()): r.set_sensitive(0) s.set_sensitive(1) else: r.set_sensitive(1) s.set_sensitive(0) t = wTree.get_widget("topCueMenu") b = wTree.get_widget("bottomCueMenu") menu = gtk.Menu() t.set_menu(menu) for n in lb.cue.keys(): i = gtk.MenuItem(n) i.show() menu.append(i) t.set_history(0) menu.show() menu = gtk.Menu() b.set_menu(menu) for n in lb.cue.keys(): i = gtk.MenuItem(n) i.show() menu.append(i) b.set_history(0) menu.show() scale = wTree.get_widget("vscale") self.adjustment = gtk.Adjustment(100.0, 0.0, 110.0, 1.0, 10.0, 10.0) self.adjustment_handler_id = self.adjustment.connect( 'value_changed', self.adjustment_changed, None) scale.set_adjustment(self.adjustment) self.tree = wTree finally: gdk.threads_leave()
def __init__(self, config, querylist, mainwin, options=None, debug=True): self.debug = debug self.conf = config self.main_window = mainwin self.sql = querylist self.db = Database.Database(self.conf, sql=self.sql) self.states = [] # List with all table states. self.window = gtk.Window() self.window.set_title("FPDB Hand Replayer") self.replayBox = gtk.VBox(False, 0) self.replayBox.show() self.window.add(self.replayBox) self.area = gtk.DrawingArea() self.pangolayout = self.area.create_pango_layout("") self.area.connect("expose-event", self.area_expose) self.style = self.area.get_style() self.gc = self.style.fg_gc[gtk.STATE_NORMAL] self.area.show() self.replayBox.pack_start(self.area, False) self.buttonBox = gtk.HButtonBox() self.buttonBox.set_layout(gtk.BUTTONBOX_SPREAD) self.startButton = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_MEDIA_PREVIOUS, gtk.ICON_SIZE_BUTTON) self.startButton.set_image(image) self.startButton.connect("clicked", self.start_clicked) self.flopButton = gtk.Button("Flop") self.flopButton.connect("clicked", self.flop_clicked) self.turnButton = gtk.Button("Turn") self.turnButton.connect("clicked", self.turn_clicked) self.riverButton = gtk.Button("River") self.riverButton.connect("clicked", self.river_clicked) self.endButton = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_MEDIA_NEXT, gtk.ICON_SIZE_BUTTON) self.endButton.set_image(image) self.endButton.connect("clicked", self.end_clicked) self.playPauseButton = gtk.Button() image = gtk.Image() image.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_BUTTON) self.playPauseButton.set_image(image) self.playPauseButton.connect("clicked", self.play_clicked) self.buttonBox.add(self.startButton) self.buttonBox.add(self.flopButton) self.buttonBox.add(self.turnButton) self.buttonBox.add(self.riverButton) self.buttonBox.add(self.endButton) self.buttonBox.add(self.playPauseButton) self.buttonBox.show_all() self.replayBox.pack_start(self.buttonBox, False) self.state = gtk.Adjustment(0, 0, 0, 1) self.stateSlider = gtk.HScale(self.state) self.stateSlider.connect("format_value", lambda x, y: "") self.stateSlider.set_digits(0) self.handler_id = self.state.connect("value_changed", self.slider_changed) self.stateSlider.show() self.replayBox.pack_start(self.stateSlider, False) self.window.show_all() self.window.connect('destroy', self.on_destroy) self.playing = False self.deck_image = "Cards01.png" #FIXME: read from config (requires deck to be defined somewhere appropriate self.tableImage = None self.playerBackdrop = None self.cardImages = None #NOTE: There are two caches of card images as I haven't found a way to # replicate the copy_area() function from Pixbuf in the Pixmap class # cardImages is used for the tables display card_images is used for the # table display. Sooner or later we should probably use one or the other. card_images = self.init_card_images(config)
def create_gradient_dialog(self): hData = self.grad.getDataFromHandle(self.grad.cur) HSVCo = gradient.RGBtoHSV(hData.col) ###GRADIENT PREVIEW### self.gradarea = gtk.DrawingArea() self.gradarea.set_size_request(256, 64) self.gradarea.connect('realize', self.gradarea_realized) self.gradarea.connect('expose_event', self.gradarea_expose) self.gradarea.add_events(gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.POINTER_MOTION_MASK) self.gradarea.connect('button-press-event', self.gradarea_mousedown) self.gradarea.connect('button-release-event', self.gradarea_clicked) self.gradarea.connect('motion-notify-event', self.gradarea_mousemoved) gradareaBox = gtk.HBox(False, 0) ###CONTEXT MENU### menu_items = (("/_Insert", "<control>I", self.add_handle, 0), ("/_Delete", "<control>D", self.rem_handle, 0), ("/_Coloring Mode", None, None, 0, "<Branch>"), ("/Coloring Mode/_RGB", "<control>R", self.cmode, 0), ("/Coloring Mode/_HSV", "<control>H", self.cmode, 1), ("/_Blending Mode", None, None, 0, "<Branch>"), ("/Blending Mode/_Linear", "<control>L", self.bmode, 0), ("/Blending Mode/_Sinusoidal", None, self.bmode, 1), ("/Blending Mode/Curved _Increasing", None, self.bmode, 2), ("/Blending Mode/Curved _Decreasing", None, self.bmode, 3), ("/Debug", None, self.printstuff, 0)) accel_group = gtk.AccelGroup() self.item_factory = gtk.ItemFactory(gtk.Menu, "<gradients>", accel_group) self.item_factory.create_items(menu_items) self.add_accel_group(accel_group) self.menu = self.item_factory.get_widget("<gradients>") ###COLOR SELECTION### if gtk.pygtk_version[0] >= 2 and gtk.pygtk_version[1] >= 4: lblCsel = gtk.Label("Color:") self.csel = gtk.ColorButton( utils.create_color(hData.col[0], hData.col[1], hData.col[2])) self.csel.connect('color-set', self.colorchanged) self.colorbutton = True else: self.csel = gtk.Button("Color...") self.csel.connect('clicked', self.cbutton_clicked) self.csel_dialog = gtk.ColorSelectionDialog("Select a Color") self.csel_dialog.colorsel.set_current_color( utils.create_color(hData.col[0], hData.col[1], hData.col[2])) self.csel_dialog.ok_button.connect('clicked', self.cdialog_response) self.colorbutton = False synccolsB = gtk.Button("Sync Colors") synccolsB.connect('clicked', self.sync_colors) CSelBox = gtk.HBox(False, 0) ###ALTERNATION CONTROL### lblAlternate = gtk.Label(_("Alternation:")) alternate = gtk.SpinButton( gtk.Adjustment(self.grad.getAlt(), 0, .5, 0.01, .5, 0.0)) alternate.set_digits(3) alternate.connect('value-changed', self.alternate_changed) AlternateBox = gtk.HBox(False, 0) ###POSITION CONTROL### lblPos = gtk.Label(_("Position:")) self.pos = gtk.SpinButton( gtk.Adjustment(hData.pos, 0, 1, 0.01, 0.1, 0.0)) self.pos.set_digits(2) self.pos.connect('value-changed', self.pos_changed) PosBox = gtk.HBox(False, 0) ###RANDOMIZE BUTTON### randomize = gtk.Button(_("Randomize")) randomize.connect('clicked', self.randomize) randBox = gtk.HBox(False, 0) ###OFFSET CONTROL### lblOffset = gtk.Label(_("Offset:")) lblOffsetBox = gtk.HBox(False, 0) offset = gtk.HScale( gtk.Adjustment(self.grad.getOffset(), 0, 1, 0.001, 0.01, 0.0)) offset.set_digits(3) offset.connect('value-changed', self.offset_changed) #################### ###WIDGET PACKING### #################### self.vbox.set_homogeneous(0) gradareaBox.pack_start(self.gradarea, 1, 0, 10) self.vbox.pack_start(gradareaBox, 0, 0, 5) if self.colorbutton: CSelBox.pack_start(lblCsel, 0, 0, 10) CSelBox.pack_start(self.csel, 0, 0, 10) CSelBox.pack_end(synccolsB, 0, 0, 10) self.vbox.pack_start(CSelBox, 0, 0, 5) PosBox.pack_start(lblPos, 0, 0, 10) PosBox.pack_start(self.pos, 0, 0, 10) self.vbox.pack_start(PosBox, 0, 0, 5) AlternateBox.pack_start(lblAlternate, 0, 0, 10) AlternateBox.pack_start(alternate, 0, 0, 10) self.vbox.pack_start(AlternateBox, 0, 0, 5) lblOffsetBox.pack_start(lblOffset, 0, 0, 5) self.vbox.pack_start(lblOffsetBox, 0, 0, 5) self.vbox.pack_start(offset, 0, 0, 5) randBox.pack_start(randomize, 1, 0, 10) self.vbox.pack_start(randBox, 0, 0, 5)
def __init__(self, configurator, handler, curr_sdk_mach, curr_distro, pclass, cpu_cnt, pmake, bbthread, selected_image_types, all_image_types, gplv3disabled, build_toolchain, build_toolchain_headers): """ """ gtk.Dialog.__init__(self, "Preferences", None, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_OK)) self.set_border_width(6) self.vbox.set_property("spacing", 12) self.action_area.set_property("spacing", 12) self.action_area.set_property("border-width", 6) self.handler = handler self.configurator = configurator self.curr_sdk_mach = curr_sdk_mach self.curr_distro = curr_distro self.curr_package_format = pclass self.cpu_cnt = cpu_cnt self.pmake = pmake self.bbthread = bbthread self.selected_image_types = selected_image_types.split(" ") self.gplv3disabled = gplv3disabled self.build_toolchain = build_toolchain self.build_toolchain_headers = build_toolchain_headers self.reload_required = False self.distro_handler_id = None self.sdk_machine_handler_id = None self.package_handler_id = None left = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) right = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) label = gtk.Label() label.set_markup("<b>Policy</b>") label.show() frame = gtk.Frame() frame.set_label_widget(label) frame.set_shadow_type(gtk.SHADOW_NONE) frame.show() self.vbox.pack_start(frame) pbox = gtk.VBox(False, 12) pbox.show() frame.add(pbox) hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) # Distro selector label = gtk.Label("Distribution:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) self.distro_combo = gtk.combo_box_new_text() self.distro_combo.set_tooltip_text( "Select the Yocto distribution you would like to use") self.distro_combo.show() hbox.pack_start(self.distro_combo, expand=False, fill=False, padding=6) # Exclude GPLv3 check = gtk.CheckButton("Exclude GPLv3 packages") check.set_tooltip_text( "Check this box to prevent GPLv3 packages from being included in your image" ) check.show() check.set_active(self.gplv3disabled) check.connect("toggled", self.include_gplv3_cb) hbox.pack_start(check, expand=False, fill=False, padding=6) hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) # Package format selector label = gtk.Label("Package format:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) self.package_combo = gtk.combo_box_new_text() self.package_combo.set_tooltip_text( """The package format is that used in creation of the root filesystem and also dictates the package manager used in your image""" ) self.package_combo.show() hbox.pack_start(self.package_combo, expand=False, fill=False, padding=6) if all_image_types: # Image output type selector label = gtk.Label("Image output types:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) chk_cnt = 3 for it in all_image_types.split(" "): chk_cnt = chk_cnt + 1 if chk_cnt % 6 == 0: hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) chk = gtk.CheckButton(it) if it in self.selected_image_types: chk.set_active(True) chk.set_tooltip_text("Build an %s image" % it) chk.connect("toggled", self.output_type_toggled_cb, handler) chk.show() hbox.pack_start(chk, expand=False, fill=False, padding=3) # BitBake label = gtk.Label() label.set_markup("<b>BitBake</b>") label.show() frame = gtk.Frame() frame.set_label_widget(label) frame.set_shadow_type(gtk.SHADOW_NONE) frame.show() self.vbox.pack_start(frame) pbox = gtk.VBox(False, 12) pbox.show() frame.add(pbox) hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) label = gtk.Label("BitBake threads:") label.show() # NOTE: may be a good idea in future to intelligently cap the maximum # values but we need more data to make an educated decision, for now # set a high maximum as a value for upper bounds is required by the # gtk.Adjustment spin_max = 30 # seems like a high enough arbitrary number #spin_max = self.cpu_cnt * 3 hbox.pack_start(label, expand=False, fill=False, padding=6) bbadj = gtk.Adjustment(value=self.bbthread, lower=1, upper=spin_max, step_incr=1) bbspinner = gtk.SpinButton(adjustment=bbadj, climb_rate=1, digits=0) bbspinner.show() bbspinner.connect("value-changed", self.change_bb_threads_cb) hbox.pack_start(bbspinner, expand=False, fill=False, padding=6) label = gtk.Label("Make threads:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) madj = gtk.Adjustment(value=self.pmake, lower=1, upper=spin_max, step_incr=1) makespinner = gtk.SpinButton(adjustment=madj, climb_rate=1, digits=0) makespinner.connect("value-changed", self.change_make_threads_cb) makespinner.show() hbox.pack_start(makespinner, expand=False, fill=False, padding=6) # Toolchain label = gtk.Label() label.set_markup("<b>External Toolchain</b>") label.show() frame = gtk.Frame() frame.set_label_widget(label) frame.set_shadow_type(gtk.SHADOW_NONE) frame.show() self.vbox.pack_start(frame) pbox = gtk.VBox(False, 12) pbox.show() frame.add(pbox) hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) toolcheck = gtk.CheckButton( "Build external development toolchain with image") toolcheck.show() toolcheck.set_active(self.build_toolchain) toolcheck.connect("toggled", self.toggle_toolchain_cb) hbox.pack_start(toolcheck, expand=False, fill=False, padding=6) hbox = gtk.HBox(False, 12) hbox.show() pbox.pack_start(hbox, expand=False, fill=False, padding=6) label = gtk.Label("Toolchain host:") label.show() hbox.pack_start(label, expand=False, fill=False, padding=6) self.sdk_machine_combo = gtk.combo_box_new_text() self.sdk_machine_combo.set_tooltip_text( "Select the host architecture of the external machine") self.sdk_machine_combo.show() hbox.pack_start(self.sdk_machine_combo, expand=False, fill=False, padding=6) headerscheck = gtk.CheckButton( "Include development headers with toolchain") headerscheck.show() headerscheck.set_active(self.build_toolchain_headers) headerscheck.connect("toggled", self.toggle_headers_cb) hbox.pack_start(headerscheck, expand=False, fill=False, padding=6) self.connect("response", self.prefs_response_cb)
def __init__(self, conf, model, selection): self.conf = conf self.model = model self.selection = selection parent = None index = model.get_value(model.get_iter(selection), ID_IND) for alarm in settings['alarmlist']: if alarm['index'] == index: date_d = alarm['date_d'] date_m = alarm['date_m'] date_y = alarm['date_y'] time_h = alarm['time_h'] time_m = alarm['time_m'] day1 = alarm['day1'] day2 = alarm['day2'] day3 = alarm['day3'] day4 = alarm['day4'] day5 = alarm['day5'] day6 = alarm['day6'] day7 = alarm['day7'] soundfile = alarm['soundfile'] cmd = alarm['cmd'] text = alarm['text'] notify = alarm['notify'] remind = alarm['remind'] index = alarm['index'] self.typealarm = 'by_date' if date_d == '': now = time.localtime() date_d = str(time.strftime('%d', now)) date_m = str(time.strftime('%m', now)) date_y = str(time.strftime('%Y', now)) self.typealarm = 'by_weekdays' # Create window self.window = gtk.Dialog(_("Edit"), parent, gtk.DIALOG_MODAL, buttons=None) self.window.set_position(gtk.WIN_POS_CENTER) frame_settings = gtk.Frame() frame_settings.set_border_width(5) box_settings = gtk.VBox(False, 0) box_settings.set_border_width(5) box_settings.set_spacing(10) frame_settings.add(box_settings) optionbox2 = gtk.HBox(False, 0) optionbox2.set_border_width(0) optionbox2.set_spacing(10) button1 = gtk.RadioButton(None, _("by date")) button1.connect("toggled", self.callback, self.typealarm) optionbox2.pack_start(button1, gtk.TRUE, gtk.TRUE, 0) button1.show() button2 = gtk.RadioButton(button1, _("by weekdays")) optionbox2.pack_start(button2, gtk.TRUE, gtk.TRUE, 0) button2.show() optionbox3 = gtk.HBox(False, 0) optionbox3.set_border_width(0) optionbox3.set_spacing(10) adjustment = gtk.Adjustment(value=int(date_d), lower=1, upper=31, step_incr=1, page_incr=1, page_size=0) self.date_d = gtk.SpinButton(adjustment=adjustment, climb_rate=0, digits=0) optionbox3.pack_start(self.date_d, False, False) adjustment = gtk.Adjustment(value=int(date_m), lower=1, upper=12, step_incr=1, page_incr=1, page_size=0) self.date_m = gtk.SpinButton(adjustment=adjustment, climb_rate=0, digits=0) optionbox3.pack_start(self.date_m, False, False) adjustment = gtk.Adjustment(value=int(date_y), lower=2011, upper=2100, step_incr=1, page_incr=1, page_size=0) self.date_y = gtk.SpinButton(adjustment=adjustment, climb_rate=0, digits=0) optionbox3.pack_start(self.date_y, False, False) adjustment = gtk.Adjustment(value=int(time_h), lower=0, upper=23, step_incr=1, page_incr=1, page_size=0) self.time_h = gtk.SpinButton(adjustment=adjustment, climb_rate=0, digits=0) optionbox3.pack_start(self.time_h, False, False) adjustment = gtk.Adjustment(value=int(time_m), lower=0, upper=59, step_incr=1, page_incr=1, page_size=0) self.time_m = gtk.SpinButton(adjustment=adjustment, climb_rate=0, digits=0) optionbox3.pack_start(self.time_m, False, False) if day1 == '': day1 = 1 if day2 == '': day2 = 1 if day3 == '': day3 = 1 if day4 == '': day4 = 1 if day5 == '': day5 = 1 if day6 == '': day6 = 1 if day7 == '': day7 = 1 self.day1 = gtk.CheckButton(_('M')) self.day1.set_active(int(day1)) self.day1.set_sensitive(False) optionbox3.pack_start(self.day1, False, False) self.day2 = gtk.CheckButton(_('T')) self.day2.set_active(int(day2)) self.day2.set_sensitive(False) optionbox3.pack_start(self.day2, False, False) self.day3 = gtk.CheckButton(_('W')) self.day3.set_active(int(day3)) self.day3.set_sensitive(False) optionbox3.pack_start(self.day3, False, False) self.day4 = gtk.CheckButton(_('Th')) self.day4.set_active(int(day4)) self.day4.set_sensitive(False) optionbox3.pack_start(self.day4, False, False) self.day5 = gtk.CheckButton(_('F')) self.day5.set_active(int(day5)) self.day5.set_sensitive(False) optionbox3.pack_start(self.day5, False, False) self.day6 = gtk.CheckButton(_('S')) self.day6.set_active(int(day6)) self.day6.set_sensitive(False) optionbox3.pack_start(self.day6, False, False) self.day7 = gtk.CheckButton(_('Su')) self.day7.set_active(int(day7)) self.day7.set_sensitive(False) optionbox3.pack_start(self.day7, False, False) self.textlabel = gtk.Label(_("Text:")) self.textlabel.set_alignment(0, 0.5) self.text = gtk.Entry() self.text.set_width_chars(55) self.text.set_text(text) self.soundlabel = gtk.Label(_("Sound file :")) self.soundlabel.set_alignment(0, 0.5) self.soundfile = gtk.Entry() soundfile = soundfile.replace("\\\"", "\"") self.soundfile.set_width_chars(55) self.soundfile.set_text(soundfile) self.cmdlabel = gtk.Label(_("Command:")) self.cmdlabel.set_alignment(0, 0.5) self.cmd = gtk.Entry() cmd = cmd.replace("\\\"", "\"") self.cmd.set_width_chars(55) self.cmd.set_text(cmd) self.index = gtk.Entry() self.index.set_text(index) self.notify = gtk.CheckButton(_('Show notify with text task')) self.notify.set_active(int(notify)) self.remind = gtk.CheckButton( _('Show notify for 5 minutes before event')) self.remind.set_active(int(remind)) self.sound_command = gtk.Button("...") self.sound_command.connect("clicked", self.button_sound_clicked) self.button_command = gtk.Button("...") self.button_command.connect("clicked", self.button_command_clicked) #Table container inside frame table = gtk.Table() table.attach(self.textlabel, 0, 1, 0, 1) table.attach(self.text, 1, 2, 0, 1) table.attach(self.soundlabel, 0, 1, 1, 2) table.attach(self.soundfile, 1, 2, 1, 2) table.attach(self.sound_command, 2, 3, 1, 2, gtk.SHRINK, gtk.SHRINK) table.attach(self.cmdlabel, 0, 1, 2, 3) table.attach(self.cmd, 1, 2, 2, 3) table.attach(self.button_command, 2, 3, 2, 3, gtk.SHRINK, gtk.SHRINK) box_settings.pack_start(optionbox2, False, False) box_settings.pack_start(optionbox3, False, False) box_settings.pack_end(self.remind, False, False) box_settings.pack_end(self.notify, False, False) box_settings.pack_end(table, False, False) self.window.vbox.pack_start(frame_settings, False, False) #self.window.set_default_size(500, 400) ## Controls bouton = gtk.Button(stock=gtk.STOCK_CANCEL) bouton.connect("clicked", self.close) self.window.action_area.pack_start(bouton, True, True, 0) bouton.show() bouton = gtk.Button(stock=gtk.STOCK_OK) bouton.connect("clicked", self.change_item) self.window.action_area.pack_start(bouton, True, True, 0) bouton.show() if self.typealarm == 'by_weekdays': button2.set_active(gtk.TRUE) #Show main window frame and all content self.window.show_all() self.window.run()
def __init__(self): self.__gobject_init__() self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.vbox_top = gtk.VBox() self.hbox_top = gtk.HBox() self.lbl_sport = gtk.Label("Serial Port:") self.ety_sport = gtk.Entry() self.ety_sport.set_text("/dev/ttyUSB0") self.adj_baudrate = gtk.Adjustment(1.0, 1.0, 12.0, 1.0, 5.0, 0.0) self.spin_baudrate = gtk.SpinButton(self.adj_baudrate, 0, 0) self.spin_baudrate.set_wrap(True) self.spin_baudrate.set_range(100, 500000) self.spin_baudrate.set_value(250000) self.btn_connect = gtk.ToggleButton("Connect to the printer") self.lbl_online = gtk.Label() self.btn_home = gtk.Button("Go Home!") self.btn_CalibrateFrontLeft = gtk.Button("Front-Left") self.btn_CalibrateFrontRight = gtk.Button("Front-Right") self.btn_CalibrateBackCenter = gtk.Button("Back-Center") self.vbox_calibration = gtk.VBox() self.hbox_calibration = gtk.HBox() self.hbox_top.pack_start(self.lbl_sport, expand=False, fill=False) self.hbox_top.pack_start(self.ety_sport, expand=False, fill=False) self.hbox_top.pack_start(self.spin_baudrate, expand=False, fill=False) self.hbox_top.pack_start(self.btn_connect, expand=False, fill=False) self.hbox_top.pack_start(self.lbl_online, expand=False, fill=False) self.hbox_top.pack_end(self.btn_home, expand=False, fill=False) self.vbox_top.pack_start(self.hbox_top, expand=False, fill=False) self.hbox_calfiltemp = gtk.HBox() #Calibration GUI self.frm_calibration = gtk.Frame("Calibration") self.alng_calibration = gtk.Alignment(0.5, 0.5, 0.5, 0.5) self.alng_calibration.add(self.frm_calibration) self.frm_calibration.add(self.vbox_calibration) self.alng_calback = gtk.Alignment(0.5, 0) self.alng_calback.add(self.btn_CalibrateBackCenter) self.alng_calfront = gtk.Alignment(0.5, 0, 0.5) self.alng_calfront.add(self.hbox_calibration) self.vbox_calibration.pack_start(self.alng_calback, expand=False, fill=False) self.vbox_calibration.pack_start(self.alng_calfront, expand=True, fill=False) self.hbox_calibration.pack_start(self.btn_CalibrateFrontLeft, expand=False, fill=False) self.hbox_calibration.pack_end(self.btn_CalibrateFrontRight, expand=False, fill=False) self.hbox_calfiltemp.pack_start(self.alng_calibration, expand=True, fill=True) #Filament GUI self.frm_filament = gtk.Frame("Filament Load/Unload") self.alng_filament = gtk.Alignment(0.5, 0.5, 0.5, 0.5) self.alng_filament.add(self.frm_filament) self.vbox_filament = gtk.VBox() self.btn_filamentLoad = gtk.Button("Load Filament") self.btn_filamentUnload = gtk.Button("Unload Filament") self.vbox_filament.pack_start(self.btn_filamentLoad, expand=False, fill=False) self.vbox_filament.pack_end(self.btn_filamentUnload, expand=False, fill=False) self.frm_filament.add(self.vbox_filament) self.hbox_calfiltemp.pack_start(self.alng_filament, expand=True, fill=False) #Temperature monitor GUI self.frm_temp = gtk.Frame("Heater Control") self.alng_temp = gtk.Alignment(0.5, 0.5, 0.5, 0.5) self.alng_temp.add(self.frm_temp) self.vbox_temp = gtk.VBox() self.frm_temp.add(self.vbox_temp) self.hbox_tempMon = gtk.HBox() self.vbox_temp.pack_start(self.hbox_tempMon) self.lbl_temp = gtk.Label("Temperature:") self.hbox_tempMon.pack_start(self.lbl_temp) self.lbl_tempMon = gtk.Label("---") self.hbox_tempMon.pack_start(self.lbl_tempMon) self.hbox_tempSet = gtk.HBox() self.lbl_tempSet = gtk.Label("Set temperature:") self.spin_temp = gtk.SpinButton(digits=1) self.spin_temp.set_range(0.0, 250.0) self.spin_temp.set_value(15.0) self.hbox_tempSet.pack_start(self.lbl_tempSet) self.hbox_tempSet.pack_start(self.spin_temp) self.vbox_temp.pack_start(self.hbox_tempSet) self.hbox_calfiltemp.pack_start(self.alng_temp) self.vbox_top.pack_start(self.hbox_calfiltemp) self.window.add(self.vbox_top) self.window.set_size_request(650, 300) self.window.show_all() self.btn_home.connect("clicked", self.btn_home_clicked, None) self.btn_connect.connect("toggled", self.btn_connect_clicked, None) self.btn_CalibrateBackCenter.connect("clicked", self.btn_rungcode_clicked, self._GCODE_FILE_CALIBRATION_BACK) self.btn_CalibrateFrontRight.connect( "clicked", self.btn_rungcode_clicked, self._GCODE_FILE_CALIBRATION_FRONTRIGHT) self.btn_CalibrateFrontLeft.connect( "clicked", self.btn_rungcode_clicked, self._GCODE_FILE_CALIBRATION_FRONTLEFT) self.btn_filamentLoad.connect("clicked", self.btn_rungcode_clicked, self._GCODE_FILE_FILAMENT_LOAD) self.btn_filamentUnload.connect("clicked", self.btn_rungcode_clicked, self._GCODE_FILE_FILAMENT_UNLOAD) self.spin_temp.connect("value-changed", self.spin_temp_changed) self.connect("serial_thread_end", self.serial_thred_end_callback) self.window.connect("destroy", self.destroy) self.window.connect("delete_event", self.delete_event) self.TemperatureMeasureTimer = gtk.timeout_add(1000, self.tempMeasurment) self.btn_home.set_sensitive(False) self.frm_calibration.set_sensitive(False) self.frm_filament.set_sensitive(False) self.frm_temp.set_sensitive(False)
def __init__(self): Element.__init__(self,_('Disable target for')) self.duration = gtk.SpinButton(gtk.Adjustment(1,0,86400000,1,10),digits=3)
def make_preferences_dialog(self): # TODO: switch to something declarative or at least clean-up the following mess self.prefs = prefs = gtk.Dialog(APP_NAME, None, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) prefs.connect("response", self.on_preferences_changed) prefs.connect("delete-event", self.on_preferences_changed) def on_sb_time_changed(widget, data=None): self.options.timeout = widget.get_value() self.update_buff_len(self.sb_buff_len) self.on_change_mode() self.logger.debug("Timeout value changed: %f." % self.options.timeout) def on_cbox_sizes_changed(widget, data=None): index = widget.get_active() self.options.font_size = FONT_SIZES.keys()[index] self.update_geometry() self.logger.debug("Window size changed: %s." % self.options.font_size) def on_cbox_modes_changed(widget, data=None): index = widget.get_active() self.options.key_mode = KEY_MODES.keys()[index] self.on_change_mode() self.logger.debug("Key mode changed: %s." % self.options.key_mode) def on_cbox_bak_changed(widget, data=None): index = widget.get_active() self.options.bak_mode = BAK_MODES.keys()[index] self.on_change_mode() self.logger.debug("Bak mode changed: %s." % self.options.bak_mode) def on_cbox_mods_changed(widget, data=None): index = widget.get_active() self.options.mods_mode = MODS_MODES.keys()[index] self.on_change_mode() self.logger.debug("Mods mode changed: %s." % self.options.mods_mode) def on_cbox_modsonly_changed(widget, data=None): self.options.mods_only = widget.get_active() self.on_change_mode() self.logger.debug("Modifiers only changed: %s." % self.options.mods_only) def on_cbox_visshift_changed(widget, data=None): self.options.vis_shift = widget.get_active() self.on_change_mode() self.logger.debug("Visible Shift changed: %s." % self.options.vis_shift) def on_cbox_visspace_changed(widget, data=None): self.options.vis_space = widget.get_active() self.on_change_mode() self.logger.debug("Show Whitespace changed: %s." % self.options.vis_space) def on_cbox_position_changed(widget, data=None): index = widget.get_active() new_position = POSITIONS.keys()[index] if new_position == 'fixed': new_geom = on_btn_sel_geom(widget) if not new_geom: self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) return elif self.options.position == 'fixed': # automatically clear geometry self.options.geometry = None self.options.position = new_position self.update_geometry() self.logger.debug("Window position changed: %s." % self.options.position) def on_cbox_screen_changed(widget, data=None): self.options.screen = widget.get_active() self.set_active_monitor(self.options.screen) self.logger.debug("Screen changed: %d." % self.options.screen) def on_cbox_persist_changed(widget, data=None): self.options.persist = widget.get_active() if not self.get_property('visible'): self.show() else: self.on_label_change(self.label.get_text()) self.logger.debug("Persistent changed: %s." % self.options.persist) def on_sb_compr_changed(widget, data=None): self.options.compr_cnt = widget.get_value_as_int() self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_sb_buff_len_changed(widget, data=None): self.options.buff_len = widget.get_value_as_int() self.update_buff_len(widget) self.on_change_mode() #self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_cbox_compr_changed(widget, data=None): compr_enabled = widget.get_active() self.sb_compr.set_sensitive(compr_enabled) self.options.compr_cnt = self.sb_compr.get_value_as_int( ) if compr_enabled else 0 self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_btn_sel_geom(widget, data=None): try: ret = subprocess.check_output(['slop', '-f', '%x %y %w %h']) except subprocess.CalledProcessError: return False except OSError: msg = gtk.MessageDialog( parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format="Error running \"slop\"") msg.format_secondary_markup( "\"slop\" is required for interactive selection. " "See <a href=\"https://github.com/naelstrof/slop\">" "https://github.com/naelstrof/slop</a>") msg.run() msg.destroy() return False self.options.geometry = map(int, ret.split(' ')) self.update_geometry() self.btn_reset_geom.set_sensitive(True) return True def on_btn_reset_geom(widget, data=None): self.options.geometry = None if self.options.position == 'fixed': self.options.position = 'bottom' self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) self.update_geometry() widget.set_sensitive(False) def on_adj_opacity_changed(widget, data=None): self.options.opacity = widget.get_value() self.update_colors() def on_font_color_changed(widget, data=None): self.options.font_color = widget.get_color().to_string() self.update_colors() def on_bg_color_changed(widget, data=None): self.options.bg_color = widget.get_color().to_string() self.update_colors() def on_btn_font(widget, data=None): self.options.font_desc = widget.get_font_name() self.font = pango.FontDescription(self.options.font_desc) self.update_label() frm_main = gtk.Frame(_("Preferences")) frm_main.set_border_width(6) frm_time = gtk.Frame("<b>%s</b>" % _("Time")) frm_time.set_border_width(4) frm_time.get_label_widget().set_use_markup(True) frm_time.set_shadow_type(gtk.SHADOW_NONE) vbox_time = gtk.VBox(spacing=6) hbox_time = gtk.HBox() lbl_time1 = gtk.Label(_("Display for")) lbl_time2 = gtk.Label(_("seconds")) sb_time = gtk.SpinButton(digits=1) sb_time.set_increments(0.5, 1.0) sb_time.set_range(0.0, 10.0) sb_time.set_numeric(True) sb_time.set_update_policy(gtk.UPDATE_IF_VALID) sb_time.set_value(self.options.timeout) sb_time.connect("value-changed", on_sb_time_changed) hbox_time.pack_start(lbl_time1, expand=False, fill=False, padding=6) hbox_time.pack_start(sb_time, expand=False, fill=False, padding=4) hbox_time.pack_start(lbl_time2, expand=False, fill=False, padding=4) vbox_time.pack_start(hbox_time) chk_persist = gtk.CheckButton(_("Persistent window")) chk_persist.connect("toggled", on_cbox_persist_changed) chk_persist.set_active(self.options.persist) vbox_time.pack_start(chk_persist) # max-chars lbl_buff_len = gtk.Label(_("Buffer size")) self.sb_buff_len = sb_buff_len = gtk.SpinButton(digits=0) sb_buff_len.set_increments(100, 100) sb_buff_len.set_range(50, 1000) sb_buff_len.set_numeric(True) sb_buff_len.set_update_policy(gtk.UPDATE_IF_VALID) sb_buff_len.set_value(self.options.buff_len or 50) sb_buff_len.connect("value-changed", on_sb_buff_len_changed) hbox_buff_len = gtk.HBox() hbox_buff_len.pack_start(lbl_buff_len, expand=False, fill=False, padding=6) hbox_buff_len.pack_start(sb_buff_len, expand=False, fill=False, padding=4) vbox_time.pack_start(hbox_buff_len) # frm_time.add(vbox_time) frm_time.show_all() frm_position = gtk.Frame("<b>%s</b>" % _("Position")) frm_position.set_border_width(4) frm_position.get_label_widget().set_use_markup(True) frm_position.set_shadow_type(gtk.SHADOW_NONE) vbox_position = gtk.VBox(spacing=6) lbl_screen = gtk.Label(_("Screen")) cbox_screen = gtk.combo_box_new_text() scr = self.get_screen() for n in range(scr.get_n_monitors()): cbox_screen.insert_text( n, '%d: %s' % (n, scr.get_monitor_plug_name(n))) cbox_screen.set_active(self.monitor) cbox_screen.connect("changed", on_cbox_screen_changed) hbox0_position = gtk.HBox() hbox0_position.pack_start(lbl_screen, expand=False, fill=False, padding=6) hbox0_position.pack_start(cbox_screen, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox0_position) lbl_positions = gtk.Label(_("Position")) self.cbox_positions = cbox_positions = gtk.combo_box_new_text() cbox_positions.set_name('position') for key, value in enumerate(POSITIONS): cbox_positions.insert_text(key, value) cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) cbox_positions.connect("changed", on_cbox_position_changed) self.btn_reset_geom = btn_reset_geom = gtk.Button(_("Reset")) btn_reset_geom.connect("clicked", on_btn_reset_geom) btn_reset_geom.set_sensitive(self.options.geometry is not None) hbox1_position = gtk.HBox() hbox1_position.pack_start(lbl_positions, expand=False, fill=False, padding=6) hbox1_position.pack_start(cbox_positions, expand=False, fill=False, padding=4) hbox1_position.pack_start(btn_reset_geom, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox1_position) btn_sel_geom = gtk.Button(_("Select window/region")) btn_sel_geom.connect("clicked", on_btn_sel_geom) vbox_position.pack_start(btn_sel_geom) frm_aspect = gtk.Frame("<b>%s</b>" % _("Aspect")) frm_aspect.set_border_width(4) frm_aspect.get_label_widget().set_use_markup(True) frm_aspect.set_shadow_type(gtk.SHADOW_NONE) vbox_aspect = gtk.VBox(spacing=6) frm_position.add(vbox_position) hbox0_font = gtk.HBox() lbl_font = gtk.Label(_("Font")) btn_font = gtk.FontButton(self.options.font_desc) btn_font.set_use_size(False) btn_font.set_show_size(False) btn_font.connect("font-set", on_btn_font) hbox0_font.pack_start(lbl_font, expand=False, fill=False, padding=6) hbox0_font.pack_start(btn_font, expand=False, fill=False, padding=4) hbox2_aspect = gtk.HBox() lbl_sizes = gtk.Label(_("Size")) cbox_sizes = gtk.combo_box_new_text() cbox_sizes.set_name('size') for key, value in enumerate(FONT_SIZES): cbox_sizes.insert_text(key, value) cbox_sizes.set_active(FONT_SIZES.keys().index(self.options.font_size)) cbox_sizes.connect("changed", on_cbox_sizes_changed) hbox2_aspect.pack_start(lbl_sizes, expand=False, fill=False, padding=6) hbox2_aspect.pack_start(cbox_sizes, expand=False, fill=False, padding=4) hbox3_font_color = gtk.HBox() lbl_font_color = gtk.Label(_("Font color")) btn_font_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.font_color)) btn_font_color.connect("color-set", on_font_color_changed) btn_bg_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.bg_color)) btn_bg_color.connect("color-set", on_bg_color_changed) hbox3_font_color.pack_start(lbl_font_color, expand=False, fill=False, padding=6) hbox3_font_color.pack_start(btn_font_color, expand=False, fill=False, padding=4) hbox3_font_color.pack_start(btn_bg_color, expand=False, fill=False, padding=4) hbox4_aspect = gtk.HBox() lbl_opacity = gtk.Label(_("Opacity")) adj_opacity = gtk.Adjustment(self.options.opacity, 0.1, 1.0, 0.1, 0, 0) adj_opacity.connect("value-changed", on_adj_opacity_changed) adj_scale = gtk.HScale(adj_opacity) hbox4_aspect.pack_start(lbl_opacity, expand=False, fill=False, padding=6) hbox4_aspect.pack_start(adj_scale, expand=True, fill=True, padding=4) vbox_aspect.pack_start(hbox0_font) vbox_aspect.pack_start(hbox2_aspect) vbox_aspect.pack_start(hbox3_font_color) vbox_aspect.pack_start(hbox4_aspect) frm_aspect.add(vbox_aspect) frm_kbd = gtk.Frame("<b>%s</b>" % _("Keys")) frm_kbd.set_border_width(4) frm_kbd.get_label_widget().set_use_markup(True) frm_kbd.set_shadow_type(gtk.SHADOW_NONE) vbox_kbd = gtk.VBox(spacing=6) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Keyboard mode")) cbox_modes = gtk.combo_box_new_text() cbox_modes.set_name('mode') for key, value in enumerate(KEY_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(KEY_MODES.keys().index(self.options.key_mode)) cbox_modes.connect("changed", on_cbox_modes_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Backspace mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(BAK_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(BAK_MODES.keys().index(self.options.bak_mode)) cbox_modes.connect("changed", on_cbox_bak_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Modifiers mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(MODS_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(MODS_MODES.keys().index(self.options.mods_mode)) cbox_modes.connect("changed", on_cbox_mods_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) chk_kbd = gtk.CheckButton(_("Show Modifier sequences only")) chk_kbd.connect("toggled", on_cbox_modsonly_changed) chk_kbd.set_active(self.options.mods_only) vbox_kbd.pack_start(chk_kbd) chk_kbd = gtk.CheckButton(_("Always show Shift")) chk_kbd.connect("toggled", on_cbox_visshift_changed) chk_kbd.set_active(self.options.vis_shift) vbox_kbd.pack_start(chk_kbd) chk_vspace = gtk.CheckButton(_("Show Whitespace characters")) chk_vspace.set_active(self.options.vis_space) chk_vspace.connect("toggled", on_cbox_visspace_changed) vbox_kbd.pack_start(chk_vspace) hbox_compr = gtk.HBox() chk_compr = gtk.CheckButton(_("Compress repeats after")) chk_compr.set_active(self.options.compr_cnt > 0) chk_compr.connect("toggled", on_cbox_compr_changed) self.sb_compr = sb_compr = gtk.SpinButton(digits=0) sb_compr.set_increments(1, 1) sb_compr.set_range(1, 100) sb_compr.set_numeric(True) sb_compr.set_update_policy(gtk.UPDATE_IF_VALID) sb_compr.set_value(self.options.compr_cnt or 3) sb_compr.connect("value-changed", on_sb_compr_changed) hbox_compr.pack_start(chk_compr, expand=False, fill=False) hbox_compr.pack_start(sb_compr, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_compr) frm_kbd.add(vbox_kbd) hbox_main = gtk.HBox() vbox_main = gtk.VBox() vbox_main.pack_start(frm_time, False, False, 6) vbox_main.pack_start(frm_position, False, False, 6) vbox_main.pack_start(frm_aspect, False, False, 6) hbox_main.pack_start(vbox_main) vbox_main = gtk.VBox() vbox_main.pack_start(frm_kbd, False, False, 6) hbox_main.pack_start(vbox_main) frm_main.add(hbox_main) prefs.vbox.pack_start(frm_main) prefs.set_destroy_with_parent(True) prefs.set_resizable(False) prefs.set_has_separator(False) prefs.set_default_response(gtk.RESPONSE_CLOSE) prefs.vbox.show_all()
def __init__(self): Element.__init__(self,_('Sleep')) self.sleeptime = gtk.SpinButton(gtk.Adjustment(1,0,86400,1,10),digits=0)
def ask(self, callback): self.callback = callback window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("TeX Text") window.set_default_size(600, 400) label1 = gtk.Label(u"Preamble file:") label2 = gtk.Label(u"Scale factor:") label3 = gtk.Label(u"Text:") if hasattr(gtk, 'FileChooserButton'): self._preamble = gtk.FileChooserButton("...") if os.path.exists(self.preamble_file): self._preamble.set_filename(self.preamble_file) self._preamble.set_action(gtk.FILE_CHOOSER_ACTION_OPEN) else: self._preamble = gtk.Entry() self._preamble.set_text(self.preamble_file) self._scale_adj = gtk.Adjustment(lower=0.01, upper=100, step_incr=0.1, page_incr=1) self._scale = gtk.SpinButton(self._scale_adj, digits=2) if self.scale_factor is not None: self._scale_adj.set_value(self.scale_factor) else: self._scale_adj.set_value(1.0) self._scale.set_sensitive(False) self._text = gtk.TextView() self._text.get_buffer().set_text(self.text) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) sw.add(self._text) self._ok = gtk.Button(stock=gtk.STOCK_OK) self._cancel = gtk.Button(stock=gtk.STOCK_CANCEL) # layout table = gtk.Table(3, 2, False) table.attach(label1, 0,1,0,1,xoptions=0,yoptions=gtk.FILL) table.attach(self._preamble, 1,2,0,1,yoptions=gtk.FILL) table.attach(label2, 0,1,1,2,xoptions=0,yoptions=gtk.FILL) table.attach(self._scale, 1,2,1,2,yoptions=gtk.FILL) table.attach(label3, 0,1,2,3,xoptions=0,yoptions=gtk.FILL) table.attach(sw, 1,2,2,3) vbox = gtk.VBox(False, 5) vbox.pack_start(table) hbox = gtk.HButtonBox() hbox.add(self._ok) hbox.add(self._cancel) hbox.set_layout(gtk.BUTTONBOX_SPREAD) vbox.pack_end(hbox, expand=False, fill=False) window.add(vbox) # signals window.connect("delete-event", self.cb_delete_event) window.connect("key-press-event", self.cb_key_press) self._ok.connect("clicked", self.cb_ok) self._cancel.connect("clicked", self.cb_cancel) # show window.show_all() self._text.grab_focus() # run self._window = window gtk.main() return self.text, self.preamble_file, self.scale_factor
def __init__(self,camera): ScriptBlock.__init__(self,camera) self.l = gtk.Label(_('Repeat')) self.l.set_alignment(0,0.5) self.count = gtk.SpinButton(gtk.Adjustment(1,1,sys.maxint,1,10))
def __init__(self, default=0, bounds=(0, 100, 5)): step = bounds[2] self.adj = gtk.Adjustment(default, bounds[0], bounds[1], step, 10 * step, 0) gtk.HScale.__init__(self, self.adj) self.set_digits(precision(step))
def __init__(self): gtk.VBox.__init__(self) from application import get_app app = get_app() self.app = app self.set_spacing(SPACING_CRAMPED) self.set_border_width(SPACING_CRAMPED) # Layer treeview # The 'object' column is a layer. All displayed columns use data from it. store = self.liststore = gtk.ListStore(object) store.connect("row-deleted", self.liststore_drag_row_deleted_cb) view = self.treeview = gtk.TreeView(store) view.connect("cursor-changed", self.treeview_cursor_changed_cb) view.set_reorderable(True) view.set_headers_visible(False) view.connect("button-press-event", self.treeview_button_press_cb) view_scroll = gtk.ScrolledWindow() view_scroll.set_shadow_type(gtk.SHADOW_ETCHED_IN) view_scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) view_scroll.add(view) view_scroll.set_size_request(-1, 100) renderer = gtk.CellRendererPixbuf() col = self.visible_col = gtk.TreeViewColumn(_("Visible")) col.pack_start(renderer, expand=False) col.set_cell_data_func(renderer, self.layer_visible_datafunc) view.append_column(col) renderer = gtk.CellRendererPixbuf() col = self.locked_col = gtk.TreeViewColumn(_("Locked")) col.pack_start(renderer, expand=False) col.set_cell_data_func(renderer, self.layer_locked_datafunc) view.append_column(col) renderer = gtk.CellRendererText() col = self.name_col = gtk.TreeViewColumn(_("Name")) col.pack_start(renderer, expand=True) col.set_cell_data_func(renderer, self.layer_name_datafunc) view.append_column(col) # Controls for the current layer layer_ctrls_table = gtk.Table() layer_ctrls_table.set_row_spacings(SPACING_CRAMPED) layer_ctrls_table.set_col_spacings(SPACING_CRAMPED) row = 0 layer_mode_lbl = gtk.Label(_('Mode:')) layer_mode_lbl.set_tooltip_text( _("Blending mode: how the current layer combines with the " "layers underneath it.")) layer_mode_lbl.set_alignment(0, 0.5) self.layer_mode_model = make_composite_op_model() self.layer_mode_combo = gtk.ComboBox() self.layer_mode_combo.set_model(self.layer_mode_model) cell1 = gtk.CellRendererText() self.layer_mode_combo.pack_start(cell1) self.layer_mode_combo.add_attribute(cell1, "text", 1) layer_ctrls_table.attach(layer_mode_lbl, 0, 1, row, row + 1, gtk.FILL) layer_ctrls_table.attach(self.layer_mode_combo, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND) row += 1 opacity_lbl = gtk.Label(_('Opacity:')) opacity_lbl.set_tooltip_text( _("Layer opacity: how much of the current layer to use. Smaller " "values make it more transparent.")) opacity_lbl.set_alignment(0, 0.5) adj = gtk.Adjustment(lower=0, upper=100, step_incr=1, page_incr=10) self.opacity_scale = gtk.HScale(adj) self.opacity_scale.set_draw_value(False) layer_ctrls_table.attach(opacity_lbl, 0, 1, row, row + 1, gtk.FILL) layer_ctrls_table.attach(self.opacity_scale, 1, 2, row, row + 1, gtk.FILL | gtk.EXPAND) # Layer list action buttons add_action = self.app.find_action("NewLayerFG") move_up_action = self.app.find_action("RaiseLayerInStack") move_down_action = self.app.find_action("LowerLayerInStack") merge_down_action = self.app.find_action("MergeLayer") del_action = self.app.find_action("RemoveLayer") duplicate_action = self.app.find_action("DuplicateLayer") add_button = self.add_button = action_button(add_action) move_up_button = self.move_up_button = action_button(move_up_action) move_down_button = self.move_down_button = action_button( move_down_action) merge_down_button = self.merge_down_button = action_button( merge_down_action) del_button = self.del_button = action_button(del_action) duplicate_button = self.duplicate_button = action_button( duplicate_action) buttons_hbox = gtk.HBox() buttons_hbox.pack_start(add_button) buttons_hbox.pack_start(move_up_button) buttons_hbox.pack_start(move_down_button) buttons_hbox.pack_start(duplicate_button) buttons_hbox.pack_start(merge_down_button) buttons_hbox.pack_start(del_button) # Pack and add to toplevel self.pack_start(layer_ctrls_table, expand=False) self.pack_start(view_scroll) self.pack_start(buttons_hbox, expand=False) # Names for anonymous layers # app.filehandler.file_opened_observers.append(self.init_anon_layer_names) ## TODO: may need to reset them with the new system too # Updates doc = app.doc.model doc.doc_observers.append(self.update) self.opacity_scale.connect('value-changed', self.on_opacity_changed) self.layer_mode_combo.connect('changed', self.on_layer_mode_changed) self.is_updating = False self.update(doc) # Observe strokes, and scroll to the highlighted row when the user # draws something. doc.stroke_observers.append(self.on_stroke)
# any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import gtk import pypulse adjust = gtk.Adjustment(value=60000, lower=0, upper=100000, step_incr=1, page_incr=1) def sink_changed(handle, index): print "DEBUG sink_changed", handle, index #output_volume = pypulse.PULSE.get_output_volume() #adjust.value = output_volume[1][0] def value_changed(widget): print "DEBUG value_changed", widget.value # TODO: you can changed the index (here is 1) based on your devices #pypulse.PULSE.set_output_volume(1, (widget.value, widget.value)) pypulse.PULSE.set_output_volume_with_balance(1, int(widget.value), 0.0)
def save(self, widget): parent = get_toplevel_window() dia = gtk.Dialog(_('Image Size'), parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) cancel_button = dia.add_button('gtk-cancel', gtk.RESPONSE_CANCEL) cancel_button.set_always_show_image(True) ok_button = dia.add_button('gtk-ok', gtk.RESPONSE_OK) ok_button.set_always_show_image(True) dia.set_icon(TRYTON_ICON) dia.set_default_response(gtk.RESPONSE_OK) hbox = gtk.HBox(spacing=3) dia.vbox.pack_start(hbox, False, True) hbox.pack_start(gtk.Label(_('Width:')), False, True) spinwidth = gtk.SpinButton() spinwidth.configure(gtk.Adjustment(400.0, 0.0, sys.maxint, 1.0, 10.0), climb_rate=1, digits=0) spinwidth.set_numeric(True) spinwidth.set_activates_default(True) hbox.pack_start(spinwidth, True, True) hbox.pack_start(gtk.Label(_('Height:')), False, True) spinheight = gtk.SpinButton() spinheight.configure(gtk.Adjustment(200.0, 0.0, sys.maxint, 1.0, 10.0), climb_rate=1, digits=0) spinheight.set_numeric(True) spinheight.set_activates_default(True) hbox.pack_start(spinheight, True, True) dia.show_all() filter = gtk.FileFilter() filter.set_name(_('PNG image (*.png)')) filter.add_mime_type('image/png') filter.add_pattern('*.png') while True: response = dia.run() width = spinwidth.get_value_as_int() height = spinheight.get_value_as_int() if response == gtk.RESPONSE_OK: filename = file_selection(_('Save As'), action=gtk.FILE_CHOOSER_ACTION_SAVE, preview=False, filters=[filter]) if width and height and filename: if not filename.endswith('.png'): filename = filename + '.png' try: self.widgets['root'].export_png( filename, width, height) break except MemoryError: message(_('Image size too large.'), dia, gtk.MESSAGE_ERROR) else: break parent.present() dia.destroy()
def __init__(self, teacher): abstract.Gui.__init__(self, teacher) self.g_percentage = gu.bLabel(self.practise_box, "") self.g_percentage.set_name("Heading1") self.g_piano = inputwidgets.PianoOctaveWithAccelName( self.on_answer_from_user, self.get_accel_key_list()) self.g_piano.m_visible_accels = not self.get_bool('hide_piano_accels') def update_accels(*ignore): self.g_piano.m_keys = self.get_accel_key_list() self.g_piano.queue_draw() for notename in mpd.MusicalPitch.notenames: self.add_watch('tone_%s_ak' % notename, update_accels) self.practise_box.pack_start(self.g_piano) self.g_flashbar = gu.FlashBar() self.g_flashbar.show() self.practise_box.pack_start(self.g_flashbar, False) self.practise_box.set_spacing(gu.PAD) self.std_buttons_add( ('new-tone', self.new_question), ('repeat', lambda _o, self=self: self.m_t.play_question()), ('give_up', self.give_up)) self.practise_box.show_all() ############## # config_box # ############## self.config_box.set_spacing(gu.PAD_SMALL) self.g_config_elems = gu.bVBox(self.config_box, False) table = gtk.Table() table.set_border_width(gu.PAD_SMALL) frame = gtk.Frame(_("Weight")) self.g_config_elems.pack_start(frame, False) frame.add(table) for x, n in [(1, 'cis'), (3, 'dis'), (7, 'fis'), (9, 'gis'), (11, 'ais')]: label = gtk.Label( mpd.MusicalPitch.new_from_notename(n).get_user_notename()) label.set_name("Heading2") label.set_alignment(0.2, 1.0) table.attach(label, x, x + 2, 0, 1, xoptions=gtk.FILL) b = gu.nSpinButton(self.m_exname, n + "_weight", gtk.Adjustment(1, 0, 1000, 1, 10), digits=0) table.attach(b, x, x + 2, 1, 2, xoptions=gtk.FILL) for x, n in [(0, 'c'), (2, 'd'), (4, 'e'), (6, 'f'), (8, 'g'), (10, 'a'), (12, 'b')]: label = gtk.Label( mpd.MusicalPitch.new_from_notename(n).get_user_notename()) label.set_name("Heading2") label.set_alignment(0.35, 1.0) table.attach(label, x, x + 2, 2, 3, xoptions=gtk.FILL) b = gu.nSpinButton(self.m_exname, n + "_weight", gtk.Adjustment(1, 0, 1000, 1, 10), digits=0) table.attach(b, x, x + 2, 3, 4, xoptions=gtk.FILL) hbox = gu.bHBox(self.g_config_elems, False) hbox.pack_start(gtk.Label(_("Octave:")), False, padding=4) for oct in self.m_t.OCTAVES: b = gu.nCheckButton(self.m_exname, "octave" + str(oct), str(oct), default_value=1) hbox.pack_start(b, False) ############# self._add_auto_new_question_gui(self.config_box) ############# b = gu.nCheckButton('idtone', 'hide_piano_accels', _("Hide _piano keyboard shortcuts"), False) def show_hide_accels(checkbutton): self.g_piano.m_visible_accels = not b.get_active() b.connect('clicked', show_hide_accels) self.config_box.pack_start(b, False) # frame = gtk.Frame(_("When you guess wrong")) vbox = gtk.VBox() vbox.set_border_width(gu.PAD_SMALL) frame.add(vbox) vbox.pack_start( gu.nCheckButton(self.m_exname, "warning_sound", _("Play warning sound"))) self.config_box.pack_start(frame, False) self.config_box.show_all() ############## # statistics # ############## self.setup_statisticsviewer(statisticsviewer.StatisticsViewer, _("Identify tone"))
def __init__(self, buff, appwin, readonly=False): # Save params self.appwin = appwin self.readonly = readonly # Gather globals self.keyh = pedconfig.conf.keyh # Init vars self.xpos = 0 self.ypos = 0 self.changed = False self.needscan = True self.record = False self.recarr = [] # Macros self.undoarr = [] # Undo self.redoarr = [] # Redo self.queue = [] # Idle tasks self.colsel = False self.oldsearch = "" self.oldgoto = "" self.oldrep = "" self.xsel = -1 self.ysel = -1 self.xsel2 = -1 self.ysel2 = -1 self.mx = -1 self.my = -1 self.caret = [] self.caret.append(0) self.caret.append(0) self.focus = False self.insert = True self.startxxx = -1 self.startyyy = -1 self.hex = False self.colflag = True self.acorr = True self.scol = False self.accum = [] self.tokens = [] self.ularr = [] self.bigcaret = False self.stab = False self.honeshot = False self.initial_undo_size = 0 self.initial_redo_size = 0 self.spell = False self.spellmode = False # Init configurables self.vscgap = VSCROLLGAP self.hscgap = HSCROLLGAP self.pgup = PAGEUP self.tabstop = TABSTOP # Process buffer into list self.text = buff self.maxlinelen = 0 self.maxlines = 0 self.fired = 0 self.countup = 0 # Parent widget gtk.DrawingArea.__init__(self) self.set_flags(gtk.CAN_FOCUS | gtk.SENSITIVE) # Our font fsize = pedconfig.conf.sql.get_int("fsize") fname = pedconfig.conf.sql.get_str("fname") if fsize == 0: fsize = 14 if fname == "": fname = "Monospace" self.setfont(fname, fsize) if self.readonly: self.set_tooltip_text("Read only buffer") # Create scroll items sm = len(self.text) + self.get_height() / self.cyy + 10 self.hadj = gtk.Adjustment(0, 0, self.maxlinelen, 1, 15, 25) self.vadj = gtk.Adjustment(0, 0, sm, 1, 15, 25) self.vscroll = gtk.VScrollbar(self.vadj) self.hscroll = gtk.HScrollbar(self.hadj) # We connect scrollers after construction self.hadj.connect("value-changed", self.hscroll_cb) self.vadj.connect("value-changed", self.vscroll_cb) self.set_events(gtk.gdk.ALL_EVENTS_MASK) self.colormap = gtk.widget_get_default_colormap() self.setcol() # Set default background color if self.readonly: color = self.colormap.alloc_color("#d8d8d8") self.modify_bg(gtk.STATE_NORMAL, color) self.connect("expose-event", self.area_expose_cb) self.connect("motion-notify-event", self.area_motion) self.connect("button-press-event", self.area_button) self.connect("button-release-event", self.area_button) self.connect("key-press-event", self.area_key) self.connect("key-release-event", self.area_key) self.connect("focus", self.area_focus) self.connect("configure_event", self.configure_event) self.connect("size-request", self.size_request) self.connect("size-allocate", self.size_alloc) self.connect("scroll-event", self.scroll_event) self.connect("focus-in-event", self.focus_in_cb) self.connect("focus-out-event", self.focus_out_cb)
def __init__(self): self.dialog = gtk.Dialog( title='Food Search', flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_HELP, gtk.RESPONSE_HELP, gtk.STOCK_OK, gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)) self.dialog.set_default_response(gtk.RESPONSE_OK) self.notebook = gtk.Notebook() self.dialog.vbox.pack_start(self.notebook, True, True, 0) self.notebook.set_border_width(5) self.container_txt = gtk.VBox(False, 0) self.notebook.append_page(self.container_txt, gtk.Label('Name Search')) self.box_txt = gtk.VBox(False, 5) self.container_txt.pack_start(self.box_txt, False, False, 0) self.box_txt.set_border_width(5) hbox13 = gtk.HBox(True, 0) self.box_txt.pack_start(hbox13, True, True, 0) label37 = gtk.Label('') label37.set_text_with_mnemonic('Food _group') hbox13.pack_start(label37, True, True, 5) label37.set_alignment(1, 0.5) self.txt_fg_combo = gnutr_widgets.GnutrComboBox() label37.set_mnemonic_widget(self.txt_fg_combo) hbox13.pack_start(self.txt_fg_combo, True, True, 0) hbox14 = gtk.HBox(True, 0) self.box_txt.pack_start(hbox14, True, True, 0) hbox14.set_border_width(5) label38 = gtk.Label('') label38.set_text_with_mnemonic('_Search for') hbox14.pack_start(label38, True, True, 5) label38.set_alignment(1, 0.5) self.food_name_entry = gtk.Entry() label38.set_mnemonic_widget(self.food_name_entry) hbox14.pack_start(self.food_name_entry, True, True, 0) self.food_name_entry.set_activates_default(True) hbox15 = gtk.HBox(True, 0) self.box_txt.pack_start(hbox15, True, True, 0) hbox15.set_border_width(5) hbox15.pack_start(gtk.Label(''), True, True, 0) self.use_regex_check = gtk.CheckButton('Use _regular expressions') hbox15.pack_start(self.use_regex_check, True, True, 0) self.container_table = gtk.VBox(False, 0) self.notebook.append_page(self.container_table, gtk.Label('Nutritient Search')) self.table_nutr = gtk.Table(7, 4, False) self.container_table.pack_start(self.table_nutr, True, True, 0) self.table_nutr.set_border_width(5) self.table_nutr.set_row_spacings(5) self.table_nutr.set_col_spacings(5) label40 = gtk.Label('') label40.set_text_with_mnemonic('Food _group') self.table_nutr.attach(label40, 0, 1, 0, 1, gtk.FILL, 0, 0, 0) label40.set_alignment(1, 0.5) label41 = gtk.Label('') label41.set_text_with_mnemonic('Nor_malize per') self.table_nutr.attach(label41, 0, 1, 1, 2, gtk.FILL, 0, 0, 0) label41.set_alignment(0, 1) self.nutr_fg_combo = gnutr_widgets.GnutrComboBox() label40.set_mnemonic_widget(self.nutr_fg_combo) self.table_nutr.attach(self.nutr_fg_combo, 1, 4, 0, 1, gtk.EXPAND | gtk.FILL, 0, 0, 0) label42 = gtk.Label('') label42.set_markup('<b>Nutrients to search for</b>') self.table_nutr.attach(label42, 0, 4, 3, 4, gtk.FILL, 0, 0, 0) label42.set_alignment(0, 0.5) label43 = gtk.Label('') label43.set_text_with_mnemonic('_Nutrient') self.table_nutr.attach(label43, 0, 1, 4, 5, gtk.FILL, 0, 0, 0) label43.set_alignment(1, 0.5) self.nutr_combo = gnutr_widgets.GnutrComboBox() label43.set_mnemonic_widget(self.nutr_combo) self.table_nutr.attach(self.nutr_combo, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, 0, 0, 0) label45 = gtk.Label('') label45.set_text_with_mnemonic('_Constraint') self.table_nutr.attach(label45, 2, 3, 4, 5, gtk.EXPAND | gtk.FILL, 0, 0, 0) label45.set_alignment(1, 0.5) constraint_spin_adj = gtk.Adjustment(1, -5, 5, 1, 1, 1) self.constraint_spin = gtk.SpinButton(constraint_spin_adj, 1, 0) label45.set_mnemonic_widget(self.constraint_spin) self.table_nutr.attach(self.constraint_spin, 3, 4, 4, 5, gtk.FILL, 0, 0, 0) self.constraint_spin.set_activates_default(True) label44 = gtk.Label('') label44.set_text_with_mnemonic('Number of _foods') self.table_nutr.attach(label44, 2, 3, 1, 2, gtk.EXPAND | gtk.FILL, 0, 0, 0) label44.set_alignment(1, 0.5) table2 = gtk.Table(3, 1, False) self.table_nutr.attach(table2, 3, 4, 6, 7, gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0) table2.set_row_spacings(5) self.delete_button = gtk.Button(label='_Delete') table2.attach(self.delete_button, 0, 1, 1, 2, gtk.FILL, 0, 0, 0) self.add_button = gtk.Button(label='_Add') table2.attach(self.add_button, 0, 1, 0, 1, gtk.EXPAND | gtk.FILL, 0, 0, 0) self.num_foods_entry = gtk.Entry() label44.set_mnemonic_widget(self.num_foods_entry) self.table_nutr.attach(self.num_foods_entry, 3, 4, 1, 2, gtk.FILL, 0, 0, 0) self.num_foods_entry.set_size_request(80, -1) self.num_foods_entry.set_activates_default(True) scrolledwindow1 = gtk.ScrolledWindow() scrolledwindow1.set_size_request(-1, 120) self.table_nutr.attach(scrolledwindow1, 0, 3, 6, 7, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0) self.treemodel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT) self.treeview = gtk.TreeView(self.treemodel) self.treeview.set_rules_hint(True) self.selection = self.treeview.get_selection() self.selection.set_mode(gtk.SELECTION_SINGLE) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn('Nutrient', renderer, text=0) self.treeview.append_column(column) renderer = gtk.CellRendererText() column = gtk.TreeViewColumn('Constraint', renderer, text=1) self.treeview.append_column(column) scrolledwindow1.add(self.treeview) self.norm_combo = gnutr_widgets.GnutrComboBox( (('calorie', ), ('gram', )), 0) label41.set_mnemonic_widget(self.norm_combo) self.table_nutr.attach(self.norm_combo, 1, 2, 1, 2, gtk.FILL, 0, 0, 0)
def __init__(self, settings, config, sql=None, parent=None): self.settings = settings self.config = config self.parent = parent self.importer = fpdb_import.Importer(self, self.settings, config, sql, parent) self.vbox = gtk.VBox(False, 0) self.vbox.show() self.chooser = gtk.FileChooserWidget() self.chooser.set_filename(self.settings['bulkImport-defaultPath']) self.chooser.set_select_multiple(True) self.vbox.add(self.chooser) self.chooser.show() # Table widget to hold the settings self.table = gtk.Table(rows=5, columns=5, homogeneous=False) self.vbox.add(self.table) self.table.show() # checkbox - print start/stop? self.chk_st_st = gtk.CheckButton(_('Print Start/Stop Info')) self.table.attach(self.chk_st_st, 0, 1, 0, 1, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.chk_st_st.show() self.chk_st_st.set_active(True) # label - status self.lab_status = gtk.Label(_("Hands/status print:")) self.table.attach(self.lab_status, 1, 2, 0, 1, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_status.show() self.lab_status.set_justify(gtk.JUSTIFY_RIGHT) self.lab_status.set_alignment(1.0, 0.5) # spin button - status status_adj = gtk.Adjustment( value=100, lower=0, upper=300, step_incr=10, page_incr=1, page_size=0) #not sure what upper value should be! self.spin_status = gtk.SpinButton(adjustment=status_adj, climb_rate=0.0, digits=0) self.table.attach(self.spin_status, 2, 3, 0, 1, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.spin_status.show() # label - threads self.lab_threads = gtk.Label(_("Number of threads:")) self.table.attach(self.lab_threads, 3, 4, 0, 1, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_threads.show() if not self.allowThreads: self.lab_threads.set_sensitive(False) self.lab_threads.set_justify(gtk.JUSTIFY_RIGHT) self.lab_threads.set_alignment(1.0, 0.5) # spin button - threads threads_adj = gtk.Adjustment( value=0, lower=0, upper=32, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be! self.spin_threads = gtk.SpinButton(adjustment=threads_adj, climb_rate=0.0, digits=0) self.table.attach(self.spin_threads, 4, 5, 0, 1, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.spin_threads.show() if not self.allowThreads: self.spin_threads.set_sensitive(False) # checkbox - archive file? self.is_archive = gtk.CheckButton(_('Archive File')) self.table.attach(self.is_archive, 0, 1, 1, 2, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.is_archive.show() # label - hands self.lab_hands = gtk.Label(_("Hands/file:")) self.table.attach(self.lab_hands, 1, 2, 1, 2, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_hands.show() self.lab_hands.set_justify(gtk.JUSTIFY_RIGHT) self.lab_hands.set_alignment(1.0, 0.5) # spin button - hands to import hands_adj = gtk.Adjustment( value=0, lower=0, upper=10, step_incr=1, page_incr=1, page_size=0) #not sure what upper value should be! self.spin_hands = gtk.SpinButton(adjustment=hands_adj, climb_rate=0.0, digits=0) self.table.attach(self.spin_hands, 2, 3, 1, 2, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.spin_hands.show() # label - drop indexes self.lab_drop = gtk.Label(_("Drop indexes:")) self.table.attach(self.lab_drop, 3, 4, 1, 2, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_drop.show() self.lab_drop.set_justify(gtk.JUSTIFY_RIGHT) self.lab_drop.set_alignment(1.0, 0.5) # ComboBox - drop indexes self.cb_dropindexes = gtk.combo_box_new_text() self.cb_dropindexes.append_text(_('auto')) self.cb_dropindexes.append_text(_("don't drop")) self.cb_dropindexes.append_text(_('drop')) self.cb_dropindexes.set_active(0) self.table.attach(self.cb_dropindexes, 4, 5, 1, 2, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.cb_dropindexes.show() self.cb_testmode = gtk.CheckButton(_('HUD Test mode')) self.table.attach(self.cb_testmode, 0, 1, 2, 3, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.cb_testmode.show() # label - filter self.lab_filter = gtk.Label(_("Site filter:")) self.table.attach(self.lab_filter, 1, 2, 2, 3, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_filter.show() self.lab_filter.set_justify(gtk.JUSTIFY_RIGHT) self.lab_filter.set_alignment(1.0, 0.5) # ComboBox - filter self.cbfilter = gtk.combo_box_new_text() disabled_sites = [] # move disabled sites to bottom of list self.cbfilter.append_text(_("Please select site")) for w in self.config.hhcs: try: if self.config.supported_sites[ w].enabled: # include enabled ones first print w self.cbfilter.append_text(w) else: disabled_sites.append(w) except: # self.supported_sites[w] may not exist if hud_config is bad disabled_sites.append(w) for w in disabled_sites: # then disabled ones print w self.cbfilter.append_text(w) self.cbfilter.set_active(0) self.table.attach(self.cbfilter, 2, 3, 2, 3, xpadding=10, ypadding=1, yoptions=gtk.SHRINK) self.cbfilter.show() # label - drop hudcache self.lab_hdrop = gtk.Label(_("Drop HudCache:")) self.table.attach(self.lab_hdrop, 3, 4, 2, 3, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_hdrop.show() self.lab_hdrop.set_justify(gtk.JUSTIFY_RIGHT) self.lab_hdrop.set_alignment(1.0, 0.5) # ComboBox - drop hudcache self.cb_drophudcache = gtk.combo_box_new_text() self.cb_drophudcache.append_text(_('auto')) self.cb_drophudcache.append_text(_("don't drop")) self.cb_drophudcache.append_text(_('drop')) self.cb_drophudcache.set_active(0) self.table.attach(self.cb_drophudcache, 4, 5, 2, 3, xpadding=10, ypadding=0, yoptions=gtk.SHRINK) self.cb_drophudcache.show() # button - Import self.load_button = gtk.Button( _('_Bulk Import')) # todo: rename variables to import too self.load_button.connect('clicked', self.load_clicked, _('Import clicked')) self.table.attach(self.load_button, 2, 3, 4, 5, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.load_button.show() # label - spacer (keeps rows 3 & 5 apart) self.lab_spacer = gtk.Label() self.table.attach(self.lab_spacer, 3, 5, 3, 4, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.lab_spacer.show() # label - info # self.lab_info = gtk.Label() # self.table.attach(self.lab_info, 3, 5, 4, 5, xpadding = 0, ypadding = 0, yoptions=gtk.SHRINK) # self.lab_info.show() self.progressbar = gtk.ProgressBar() self.table.attach(self.progressbar, 3, 5, 4, 5, xpadding=0, ypadding=0, yoptions=gtk.SHRINK) self.progressbar.set_text(_("Waiting...")) self.progressbar.set_fraction(0) self.progressbar.show() # see how many hands are in the db and adjust accordingly tcursor = self.importer.database.cursor tcursor.execute("Select count(1) from Hands") row = tcursor.fetchone() tcursor.close() self.importer.database.rollback() self.n_hands_in_db = row[0] if self.n_hands_in_db == 0: self.cb_dropindexes.set_active(2) self.cb_dropindexes.set_sensitive(False) self.lab_drop.set_sensitive(False) self.cb_drophudcache.set_active(2) self.cb_drophudcache.set_sensitive(False) self.lab_hdrop.set_sensitive(False)
def __init__(self, partitions, diskset, intf, parent, origrequest, isNew=0, restrictfs=None): self.partitions = partitions self.diskset = diskset self.origrequest = origrequest self.isNew = isNew self.intf = intf self.parent = parent if isNew: tstr = _("Add Partition") else: try: tstr = _("Edit Partition: /dev/%s") % (origrequest.device, ) except: tstr = _("Edit Partition") self.dialog = gtk.Dialog(tstr, self.parent) gui.addFrame(self.dialog) self.dialog.add_button('gtk-cancel', 2) self.dialog.add_button('gtk-ok', 1) self.dialog.set_position(gtk.WIN_POS_CENTER) maintable = gtk.Table() maintable.set_row_spacings(5) maintable.set_col_spacings(5) row = 0 # see if we are creating a floating request or by cylinder if self.origrequest.type == REQUEST_NEW: self.newbycyl = self.origrequest.start != None # Mount Point entry lbl = createAlignedLabel(_("_Mount Point:")) maintable.attach(lbl, 0, 1, row, row + 1) self.mountCombo = createMountPointCombo(origrequest) lbl.set_mnemonic_widget(self.mountCombo.entry) maintable.attach(self.mountCombo, 1, 2, row, row + 1) row = row + 1 # Partition Type if self.origrequest.type == REQUEST_NEW: lbl = createAlignedLabel(_("File System _Type:")) maintable.attach(lbl, 0, 1, row, row + 1) (self.newfstype, self.newfstypeMenu) = createFSTypeMenu( self.origrequest.fstype, fstypechangeCB, self.mountCombo, availablefstypes=restrictfs) lbl.set_mnemonic_widget(self.newfstype) maintable.attach(self.newfstype, 1, 2, row, row + 1) else: maintable.attach( createAlignedLabel(_("Original File System " "Type:")), 0, 1, row, row + 1) if self.origrequest.origfstype: typestr = self.origrequest.origfstype.getName() if self.origrequest.origfstype.getName() == "foreign": part = get_partition_by_name(self.diskset.disks, self.origrequest.device) typestr = map_foreign_to_fsname(part.native_type) else: typestr = _("Unknown") fstypelabel = gtk.Label(typestr) maintable.attach(fstypelabel, 1, 2, row, row + 1) self.newfstype = None self.newfstypeMenu = None row = row + 1 # allowable drives if self.origrequest.type == REQUEST_NEW: if not self.newbycyl: lbl = createAlignedLabel(_("Allowable _Drives:")) maintable.attach(lbl, 0, 1, row, row + 1) self.driveview = createAllowedDrivesList( self.diskset.disks, self.origrequest.drive) lbl.set_mnemonic_widget(self.driveview) sw = gtk.ScrolledWindow() sw.add(self.driveview) sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.set_shadow_type(gtk.SHADOW_IN) maintable.attach(sw, 1, 2, row, row + 1) self.driveview.set_size_request(375, 80) else: maintable.attach(createAlignedLabel(_("Drive:")), 0, 1, row, row + 1) maintable.attach(createAlignedLabel(origrequest.drive[0]), 1, 2, row, row + 1) row = row + 1 # original fs label if self.origrequest.type != REQUEST_NEW and self.origrequest.fslabel: maintable.attach( createAlignedLabel(_("Original File System " "Label:")), 0, 1, row, row + 1) fslabel = gtk.Label(self.origrequest.fslabel) maintable.attach(fslabel, 1, 2, row, row + 1) row = row + 1 # size if self.origrequest.type == REQUEST_NEW: if not self.newbycyl: # Size specification lbl = createAlignedLabel(_("_Size (MB):")) maintable.attach(lbl, 0, 1, row, row + 1) sizeAdj = gtk.Adjustment(value=1, lower=1, upper=MAX_PART_SIZE, step_incr=1) self.sizespin = gtk.SpinButton(sizeAdj, digits=0) self.sizespin.set_property('numeric', gtk.TRUE) if self.origrequest.size: self.sizespin.set_value(self.origrequest.size) lbl.set_mnemonic_widget(self.sizespin) maintable.attach(self.sizespin, 1, 2, row, row + 1) bycyl_sizelabel = None else: # XXX need to add partition by size and # wire in limits between start and end dev = self.diskset.disks[origrequest.drive[0]].dev maintable.attach(createAlignedLabel(_("Size (MB):")), 0, 1, row, row + 1) bycyl_sizelabel = createAlignedLabel("") maintable.attach(bycyl_sizelabel, 1, 2, row, row + 1) row = row + 1 lbl = createAlignedLabel(_("_Start Cylinder:")) maintable.attach(lbl, 0, 1, row, row + 1) maxcyl = self.diskset.disks[origrequest.drive[0]].dev.cylinders cylAdj = gtk.Adjustment(value=origrequest.start, lower=origrequest.start, upper=maxcyl, step_incr=1) self.startcylspin = gtk.SpinButton(cylAdj, digits=0) self.startcylspin.set_property('numeric', gtk.TRUE) lbl.set_mnemonic_widget(self.startcylspin) maintable.attach(self.startcylspin, 1, 2, row, row + 1) row = row + 1 endcylAdj = gtk.Adjustment(value=origrequest.end, lower=origrequest.start, upper=maxcyl, step_incr=1) lbl = createAlignedLabel(_("_End Cylinder:")) maintable.attach(lbl, 0, 1, row, row + 1) self.endcylspin = gtk.SpinButton(endcylAdj, digits=0) self.endcylspin.set_property('numeric', gtk.TRUE) lbl.set_mnemonic_widget(self.endcylspin) maintable.attach(self.endcylspin, 1, 2, row, row + 1) self.startcylspin.connect( "value-changed", self.cylspinchangedCB, (dev, self.startcylspin, self.endcylspin, bycyl_sizelabel)) self.endcylspin.connect( "value-changed", self.cylspinchangedCB, (dev, self.startcylspin, self.endcylspin, bycyl_sizelabel)) startsec = start_cyl_to_sector(dev, origrequest.start) endsec = end_cyl_to_sector(dev, origrequest.end) cursize = (endsec - startsec) / 2048 bycyl_sizelabel.set_text("%s" % (int(cursize))) else: maintable.attach(createAlignedLabel(_("Size (MB):")), 0, 1, row, row + 1) sizelabel = gtk.Label("%d" % (origrequest.size)) maintable.attach(sizelabel, 1, 2, row, row + 1) self.sizespin = None row = row + 1 # format/migrate options for pre-existing partitions self.fsoptionsDict = {} if self.origrequest.type == REQUEST_PREEXIST and self.origrequest.fstype: (row, self.fsoptionsDict) = createPreExistFSOptionSection( self.origrequest, maintable, row, self.mountCombo) # size options if self.origrequest.type == REQUEST_NEW: if not self.newbycyl: (sizeframe, self.fixedrb, self.fillmaxszrb, self.fillmaxszsb) = self.createSizeOptionsFrame( self.origrequest, self.fillmaxszCB) self.sizespin.connect("value-changed", self.sizespinchangedCB, self.fillmaxszsb) maintable.attach(sizeframe, 0, 2, row, row + 1) else: # XXX need new by cyl options (if any) pass row = row + 1 else: self.sizeoptiontable = None # create only as primary if self.origrequest.type == REQUEST_NEW: self.primonlycheckbutton = gtk.CheckButton( _("Force to be a _primary " "partition")) self.primonlycheckbutton.set_active(0) if self.origrequest.primary: self.primonlycheckbutton.set_active(1) # only show if we have something other than primary if not self.diskset.onlyPrimaryParts(): maintable.attach(self.primonlycheckbutton, 0, 2, row, row + 1) row = row + 1 # disable option for badblocks checking self.badblocks = None # uncomment to reenable #self.badblocks = gtk.CheckButton(_("Check for _bad blocks")) #self.badblocks.set_active(0) #maintable.attach(self.badblocks, 0, 1, row, row + 1) #row = row + 1 #if self.origrequest.badblocks: # self.badblocks.set_active(1) # put main table into dialog self.dialog.vbox.pack_start(maintable) self.dialog.show_all()
def _create_dialog(self, config): table, self.dialog = create_table_dialog(self.parent, "Machine configuration", 6, 4, "Set and reboot") row = 0 self.machines = table_add_radio_rows(table, row, "Machine:", config.get_machine_types(), self._machine_cb) row += 1 self.dsps = table_add_radio_rows(table, row, "DSP type:", config.get_dsp_types()) row += 1 # start next table column row = 0 table_set_col_offset(table, 2) self.monitors = table_add_radio_rows(table, row, "Monitor:", config.get_monitor_types()) row += 1 self.clocks = table_add_radio_rows(table, row, "CPU clock:", config.get_cpuclock_types()) row += 1 # fullspan at bottom fullspan = True combo = gtk.combo_box_new_text() for text in config.get_cpulevel_types(): combo.append_text(text) self.cpulevel = table_add_widget_row(table, row, "CPU type:", combo, fullspan) row += 1 combo = gtk.combo_box_new_text() for text in config.get_memory_names(): combo.append_text(text) self.memory = table_add_widget_row(table, row, "Memory:", combo, fullspan) row += 1 self.ttram = gtk.Adjustment(config.get_ttram(), 0, 260, 4, 4, 4) ttram = gtk.HScale(self.ttram) ttram.set_digits(0) ttram.set_tooltip_text( "TT-RAM needs Falcon/TT with WinUAE CPU core and implies 32-bit addressing. 0 = disabled, 24-bit addressing." ) table_add_widget_row(table, row, "TT-RAM", ttram, fullspan) row += 1 label = "TOS image:" fsel = self._fsel(label, gtk.FILE_CHOOSER_ACTION_OPEN) self.tos = table_add_widget_row(table, row, label, fsel, fullspan) row += 1 vbox = gtk.VBox() self.compatible = gtk.CheckButton("Compatible CPU") self.timerd = gtk.CheckButton("Patch Timer-D") self.compatible.set_tooltip_text( "Needed for overscan and other timing sensitive things to work correctly" ) self.timerd.set_tooltip_text( "Improves ST/STE emulation performance, but some rare demos/games don't work with this" ) vbox.add(self.compatible) vbox.add(self.timerd) table_add_widget_row(table, row, "Misc.:", vbox, fullspan) row += 1 table.show_all()