我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.Adjustment()。
def create_number_hbox(self, label, value, trace, sensitivity_group, constraints=None): hbox_main = gtk.HBox() label_text = gtk.Label(label.title()) label_text.set_alignment(0, 0.5) label_text.set_padding(8,8) adjustment = gtk.Adjustment(value, 0, sys.maxint, 1) spinbutton_value = gtk.SpinButton(adjustment) spinbutton_value.set_value(value) hbox_main.pack_start(label_text) hbox_main.pack_start(spinbutton_value) self.plugin_config_widgets.append(spinbutton_value) self.plugin_config_traces.append(trace) sensitivity_group.append(label_text) sensitivity_group.append(spinbutton_value) return hbox_main
def __init__(self, max_depth_value): self.on_max_depth_changed = None max_depth_entry = self.max_depth_entry = gtk.SpinButton( gtk.Adjustment(value=max_depth_value, lower=1, upper=100, step_incr=1, page_incr=10), digits=0) max_depth_entry.get_adjustment().connect('value_changed', self._max_depth_changed, max_depth_entry) max_depth_entry.set_alignment(0) max_depth_label = gtk.Label() max_depth_label.set_alignment(1, 0.5) max_depth_label.set_text_with_mnemonic('Maximum _Depth') max_depth_label.set_mnemonic_widget(max_depth_entry) legend = self._create_legend() table = self.view = gtk.Table(2, 3) table.set_border_width(8) table.set_row_spacings(8) table.set_col_spacings(8) table.attach(max_depth_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) table.attach(max_depth_entry, 1, 2, 0, 1, gtk.SHRINK, gtk.FILL) table.attach(gtk.Label(), 2, 3, 0, 1) # space filler table.attach(legend, 0, 3, 1, 2)
def get_mem_range(self): d = inputdialog.FieldDialog(title="Select Memory Range") limit = RADIOS[self.rtype].mem_upper_limit la = gtk.Adjustment(0, 0, limit, 1, 10, 10) d.add_field("Start", gtk.SpinButton(la, 0)) ua = gtk.Adjustment(100, 0, limit, 1, 10, 10) d.add_field("End", gtk.SpinButton(ua, 0)) r = d.run() low = int(la.get_value()) high = int(ua.get_value()) d.destroy() if r == gtk.RESPONSE_OK: return low, high else: return None, None
def __init__(self): assert Visualizer.INSTANCE is None Visualizer.INSTANCE = self super(Visualizer, self).__init__() self.nodes = {} # node index -> Node self.channels = {} # id(ns3.Channel) -> Channel self.window = None # toplevel window self.canvas = None # goocanvas.Canvas self.time_label = None # gtk.Label self.play_button = None # gtk.ToggleButton self.zoom = None # gtk.Adjustment self._scrolled_window = None # gtk.ScrolledWindow self.links_group = goocanvas.Group() self.channels_group = goocanvas.Group() self.nodes_group = goocanvas.Group() self._update_timeout_id = None self.simulation = SimulationThread(self) self.selected_node = None # node currently selected self.speed = 1.0 self.information_windows = [] self._transmission_arrows = [] self._last_transmissions = [] self._drop_arrows = [] self._last_drops = [] self._show_transmissions_mode = None self.set_show_transmissions_mode(ShowTransmissionsMode.ALL) self._panning_state = None self.node_size_adjustment = None self.transmissions_smoothing_adjustment = None self.sample_period = SAMPLE_PERIOD self.node_drag_state = None self.follow_node = None self.shell_window = None self.create_gui() for plugin in plugins: plugin(self)
def create_time_hbox(self, label, value, trace, sensitivity_group, constraints=None): hbox_main = gtk.HBox() label_text = gtk.Label(label.title()) label_text.set_alignment(0, 0.5) label_text.set_padding(8,8) adjustment = gtk.Adjustment(value, 0, sys.maxint, 1) spinbutton_value = gtk.SpinButton(adjustment) combobox_units = gtk.combo_box_new_text() t_value, units = self.get_time_value_and_units(value) spinbutton_value.set_value(t_value) options = ["seconds", "minutes", "hours", "days", "weeks"] for option in options: combobox_units.append_text(option) selected_index = options.index(units) combobox_units.set_active(selected_index) hbox_main.pack_start(label_text) hbox_main.pack_start(spinbutton_value) hbox_main.pack_start(combobox_units) self.plugin_config_widgets.append([spinbutton_value, combobox_units]) self.plugin_config_traces.append(trace) sensitivity_group.append(label_text) sensitivity_group.append(spinbutton_value) return hbox_main #TODO: Refactor these
def __init__(self, window): self.dialog = gtk.Dialog('Debug Window', window, gtk.DIALOG_MODAL, ()) self.dialog.set_destroy_with_parent(True) self.dialog.set_transient_for(window) self.dialog.set_modal(False) self.textview = gtk.TextView() self.textview.set_editable(False) self.textview.set_wrap_mode(gtk.WRAP_WORD_CHAR) self.textview.set_scroll_adjustments(gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0), gtk.Adjustment(1.0, 1.0, 100.0, 1.0, 10.0, 10.0)) self.scrolledwindow = gtk.ScrolledWindow(None, None) self.scrolledwindow.add(self.textview) self.dialog.vbox.pack_start(self.scrolledwindow) self.dialog.set_default_size(640, 480)
def spin_button(name="variable",number_type="int",value=0,min=1,max=100,advance=1): adjustment = gtk.Adjustment(value,min,max,advance,advance) digits = 0 if number_type != "int": digits = 3 l = gtk.Label(name) b = gtk.SpinButton(adjustment,0,digits) h = gtk.HBox() h.pack_start(l) h.pack_start(b) return h,adjustment
def update_config(self,widget,var_type=None): if isinstance(widget,gtk.Adjustment): value = widget.get_value() elif isinstance(widget,gtk.CheckButton): value = widget.get_active() self.atual_config[var_type] = value