def test_attach(self): entry = ProxyEntry() entry.data_type = currency self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None) calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB) pixbuf_pixels = calc.render_icon(STOQ_CALC, gtk.ICON_SIZE_MENU).get_pixels() self.assertEqual( entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) entry.set_sensitive(False) self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None) entry.set_sensitive(True) self.assertEqual( entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) spinbutton = ProxySpinButton() spinbutton.data_type = currency self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None) calc = CalculatorPopup(spinbutton, CalculatorPopup.MODE_SUB) pixbuf_pixels = calc.render_icon(STOQ_CALC, gtk.ICON_SIZE_MENU).get_pixels() self.assertEqual( spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) spinbutton.set_sensitive(False) self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None) spinbutton.set_sensitive(True) self.assertEqual( spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment( gtk.Adjustment(lower=0, step_incr=1, upper=sys.maxint, page_incr=10)) return entry
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment(Gtk.Adjustment(lower=0, step_incr=1, upper=100, page_incr=10)) entry.set_range(0, 100) entry.set_digits(2) return entry
def _create_spin(self): spin = ProxySpinButton() spin.data_type = decimal.Decimal unit = self.model.product.sellable.unit upper = self._quantity if self._validate_max_quantity else MAX_INT spin.set_adjustment(gtk.Adjustment(lower=0, upper=upper, step_incr=1, page_incr=10)) if unit and unit.allow_fraction: spin.set_digits(QUANTITY_PRECISION) self.setup_spin(spin) spin.connect_after('content-changed', self._after_spinbutton__content_changed) spin.connect('validate', self._on_spinbutton__validate) return spin
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment(Gtk.Adjustment(lower=0, step_increment=1, upper=100, page_increment=10)) entry.set_range(0, 100) entry.set_digits(2) return entry
def get_widget_for_type(rtype): if rtype is types.boolean: return ProxyCheckButton() elif rtype is types.file: w = ProxyFileChooserButton('Select File') #w.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) return w elif rtype is types.readonlyfile: w = ProxyFileChooserButton('Select File') w.set_sensitive(False) #w.set_action(gtk.FILE_CHOOSER_ACTION_SAVE) return w elif rtype in [types.directory]: w = ProxyFileChooserButton(title='Select Directory') w.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER) return w elif rtype is types.font: return ProxyFontButton() elif rtype is types.color: return CleverProxyColorButton() elif rtype is types.integer: w = ProxySpinButton() return w elif rtype.__name__ is 'intrange': adjvals = rtype.lower, rtype.upper, rtype.step adj = gtk.Adjustment(0, *adjvals) w = ProxySpinButton() w.set_adjustment(adj) return w elif rtype is types.readonly: return FormattedLabel(VC_NAME_MU) elif rtype.__name__ is 'stringlist': w = ProxyComboBox() w.set_property('data-type', str) w.prefill(rtype.choices) return w else: w = ProxyEntry(data_type=str) w.set_width_chars(18) return w
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment( Gtk.Adjustment(lower=0, step_increment=1, upper=sys.maxsize, page_increment=10)) entry.set_digits(self.digits) return entry
def _setup_spin_entry_slave(self, box=None): data_type = self.detail.get_parameter_type() widget = ProxySpinButton(data_type=data_type) widget.props.sensitive = self.sensitive widget.set_range(self.detail.range[0], self.detail.range[1]) widget.set_value(data_type(self.model.field_value)) widget.set_increments(1, 10) if issubclass(data_type, Decimal): widget.props.digits = 2 widget.connect('value-changed', self._on_spin__value_changed) if box is None: self.container.add(widget) else: box.pack_start(widget) widget.show() widget.connect('validate', self._on_entry__validate) widget.connect('validation-changed', self._on_entry__validation_changed) self._entry = widget
def test_show(self): spinbutton = ProxySpinButton() spinbutton.data_type = currency calc = CalculatorPopup(spinbutton, CalculatorPopup.MODE_SUB) self.check_widget(calc, 'calculator-popup-show')
def testForIntFloat(self): mySpinBtn = ProxySpinButton() self.assertEqual(mySpinBtn.get_property("data-type"), 'int')
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment(Gtk.Adjustment(lower=0, step_increment=1, upper=sys.maxsize, page_increment=10)) entry.set_digits(self.digits) return entry
def build_widget(self): entry = ProxySpinButton() entry.set_adjustment(gtk.Adjustment(lower=0, step_incr=1, upper=sys.maxint, page_incr=10)) return entry
def test_attach(self): entry = ProxyEntry() entry.data_type = currency self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None) calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB) pixbuf_pixels = calc.render_icon(STOQ_CALC, Gtk.IconSize.MENU).get_pixels() self.assertEqual( entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) entry.set_sensitive(False) self.assertEqual(entry.get_property('secondary-icon-pixbuf'), None) entry.set_sensitive(True) self.assertEqual( entry.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) spinbutton = ProxySpinButton() spinbutton.data_type = currency self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None) calc = CalculatorPopup(spinbutton, CalculatorPopup.MODE_SUB) pixbuf_pixels = calc.render_icon(STOQ_CALC, Gtk.IconSize.MENU).get_pixels() self.assertEqual( spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels) spinbutton.set_sensitive(False) self.assertEqual(spinbutton.get_property('secondary-icon-pixbuf'), None) spinbutton.set_sensitive(True) self.assertEqual( spinbutton.get_property('secondary-icon-pixbuf').get_pixels(), pixbuf_pixels)
def _create_spin(self): spin = ProxySpinButton() spin.data_type = decimal.Decimal unit = self.model.product.sellable.unit upper = self._quantity if self._validate_max_quantity else MAX_INT spin.set_adjustment(Gtk.Adjustment(lower=0, upper=upper, step_increment=1, page_increment=10)) if unit and unit.allow_fraction: spin.set_digits(QUANTITY_PRECISION) self.setup_spin(spin) spin.connect_after('content-changed', self._after_spinbutton__content_changed) spin.connect('validate', self._on_spinbutton__validate) return spin