Example #1
0
class DurationInputBox(gtk.HBox):
	def __init__(self):
		gtk.HBox.__init__(self)
		##
		self.valueSpin = FloatSpinButton(0, 999, 1)
		pack(self, self.valueSpin)
		##
		combo = gtk.ComboBoxText()
		for unitValue, unitName in durationUnitsAbs:
			combo.append_text(_(
				" " + unitName.capitalize() + "s"
			))
		combo.set_active(2) ## hour FIXME
		pack(self, combo)
		self.unitCombo = combo

	def getDuration(self):
		return (
			self.valueSpin.get_value(),
			durationUnitValues[self.unitCombo.get_active()],
		)

	def setDuration(self, value, unit):
		self.valueSpin.set_value(value)
		self.unitCombo.set_active(durationUnitValues.index(unit))
Example #2
0
 def __init__(self, cal, index, mode, params, sgroupLabel):
     from scal3.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
     from scal3.ui_gtk.mywidgets import MyFontButton, MyColorButton
     gtk.Frame.__init__(self)
     self.cal = cal
     self.index = index
     self.mode = mode
     ####
     module, ok = calTypes[mode]
     if not ok:
         raise RuntimeError("cal type %r not found" % mode)
     ####
     self.set_label(_(module.desc))
     ####
     vbox = gtk.VBox()
     self.add(vbox)
     ###
     hbox = gtk.HBox()
     label = gtk.Label(_("Position") + ": ")
     pack(hbox, label)
     sgroupLabel.add_widget(label)
     spin = FloatSpinButton(-99, 99, 1)
     self.spinX = spin
     pack(hbox, spin)
     pack(hbox, gtk.Label(""), 1, 1)
     spin = FloatSpinButton(-99, 99, 1)
     self.spinY = spin
     pack(hbox, spin)
     pack(hbox, gtk.Label(""), 1, 1)
     pack(vbox, hbox)
     ####
     hbox = gtk.HBox()
     label = gtk.Label(_("Font") + ": ")
     pack(hbox, label)
     sgroupLabel.add_widget(label)
     ##
     fontb = MyFontButton(cal)
     self.fontb = fontb
     ##
     colorb = MyColorButton()
     self.colorb = colorb
     ##
     pack(hbox, colorb)
     pack(hbox, gtk.Label(""), 1, 1)
     pack(hbox, fontb)
     pack(vbox, hbox)
     ####
     self.set(params)
     ####
     self.spinX.connect("changed", self.onChange)
     self.spinY.connect("changed", self.onChange)
     fontb.connect("font-set", self.onChange)
     colorb.connect("color-set", self.onChange)
Example #3
0
 def __init__(self):
     gtk.HBox.__init__(self)
     ##
     self.valueSpin = FloatSpinButton(0, 999, 1)
     pack(self, self.valueSpin)
     ##
     combo = gtk.ComboBoxText()
     for unitValue, unitName in durationUnitsAbs:
         combo.append_text(_(' '+unitName.capitalize()+'s'))
     combo.set_active(2) ## hour FIXME
     pack(self, combo)
     self.unitCombo = combo
Example #4
0
class DurationInputBox(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        ##
        self.valueSpin = FloatSpinButton(0, 999, 1)
        pack(self, self.valueSpin)
        ##
        combo = gtk.ComboBoxText()
        for unitValue, unitName in durationUnitsAbs:
            combo.append_text(_(' '+unitName.capitalize()+'s'))
        combo.set_active(2) ## hour FIXME
        pack(self, combo)
        self.unitCombo = combo
    def getDuration(self):
        return self.valueSpin.get_value(), durationUnitValues[self.unitCombo.get_active()]
    def setDuration(self, value, unit):
        self.valueSpin.set_value(value)
        self.unitCombo.set_active(durationUnitValues.index(unit))
Example #5
0
 def __init__(self, cal, index, mode, params, sgroupLabel, sgroupFont):
     from scal3.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
     from scal3.ui_gtk.mywidgets import MyFontButton, MyColorButton
     gtk.HBox.__init__(self)
     self.cal = cal
     self.index = index
     self.mode = mode
     ######
     module, ok = calTypes[mode]
     if not ok:
         raise RuntimeError("cal type %r not found" % mode)
     label = gtk.Label(_(module.desc) + "  ")
     label.set_alignment(0, 0.5)
     pack(self, label)
     sgroupLabel.add_widget(label)
     ###
     pack(self, gtk.Label(""), 1, 1)
     pack(self, gtk.Label(_("position")))
     ###
     spin = FloatSpinButton(-999, 999, 1)
     self.spinX = spin
     pack(self, spin)
     ###
     spin = FloatSpinButton(-999, 999, 1)
     self.spinY = spin
     pack(self, spin)
     ####
     pack(self, gtk.Label(""), 1, 1)
     ###
     fontb = MyFontButton(cal)
     self.fontb = fontb
     pack(self, fontb)
     sgroupFont.add_widget(fontb)
     ####
     colorb = MyColorButton()
     self.colorb = colorb
     pack(self, colorb)
     ####
     self.set(params)
     ####
     self.spinX.connect("changed", self.onChange)
     self.spinY.connect("changed", self.onChange)
     fontb.connect("font-set", self.onChange)
     colorb.connect("color-set", self.onChange)
Example #6
0
 def __init__(self, module, varName, _min, _max, digits=1):
     self.module = module
     self.varName = varName
     if digits == 0:
         w = IntSpinButton(_min, _max)
     else:
         w = FloatSpinButton(_min, _max, digits)
     self._widget = w
     self.get = w.get_value
     self.set = w.set_value
Example #7
0
 def __init__(self, cal, index, mode, params, sgroupLabel, sgroupFont):
     from scal3.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
     from scal3.ui_gtk.mywidgets import MyFontButton, MyColorButton
     gtk.HBox.__init__(self)
     self.cal = cal
     self.index = index
     self.mode = mode
     ######
     label = gtk.Label(_(calTypes[mode].desc) + '  ')
     label.set_alignment(0, 0.5)
     pack(self, label)
     sgroupLabel.add_widget(label)
     ###
     pack(self, gtk.Label(''), 1, 1)
     pack(self, gtk.Label(_('position')))
     ###
     spin = FloatSpinButton(-999, 999, 1)
     self.spinX = spin
     pack(self, spin)
     ###
     spin = FloatSpinButton(-999, 999, 1)
     self.spinY = spin
     pack(self, spin)
     ####
     pack(self, gtk.Label(''), 1, 1)
     ###
     fontb = MyFontButton(cal)
     self.fontb = fontb
     pack(self, fontb)
     sgroupFont.add_widget(fontb)
     ####
     colorb = MyColorButton()
     self.colorb = colorb
     pack(self, colorb)
     ####
     self.set(params)
     ####
     self.spinX.connect('changed', self.onChange)
     self.spinY.connect('changed', self.onChange)
     fontb.connect('font-set', self.onChange)
     colorb.connect('color-set', self.onChange)
Example #8
0
 def __init__(self):
     gtk.HBox.__init__(self)
     ##
     self.valueSpin = FloatSpinButton(0, 999, 1)
     pack(self, self.valueSpin)
     ##
     combo = gtk.ComboBoxText()
     for unitValue, unitName in durationUnitsAbs:
         combo.append_text(_(' '+unitName.capitalize()+'s'))
     combo.set_active(2) ## hour FIXME
     pack(self, combo)
     self.unitCombo = combo
Example #9
0
	def optionsWidgetCreate(self):
		from scal3.ui_gtk.mywidgets.multi_spin.integer import IntSpinButton
		from scal3.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
		from scal3.ui_gtk.pref_utils import CheckPrefItem, ColorPrefItem
		if self.optionsWidget:
			return
		ColumnBase.optionsWidgetCreate(self)
		#####
		hbox = gtk.HBox()
		spin = IntSpinButton(1, 9999)
		spin.set_value(ui.wcalHeight)
		spin.connect('changed', self.heightSpinChanged)
		pack(hbox, gtk.Label(_('Height')))
		pack(hbox, spin)
		pack(self.optionsWidget, hbox)
		###
		hbox = gtk.HBox()
		spin = FloatSpinButton(0.01, 1, 2)
		spin.set_value(ui.wcalTextSizeScale)
		spin.connect('changed', self.textSizeScaleSpinChanged)
		pack(hbox, gtk.Label(_('Text Size Scale')))
		pack(hbox, spin)
		pack(self.optionsWidget, hbox)
		########
		hbox = gtk.HBox(spacing=3)
		####
		item = CheckPrefItem(ui, 'wcalGrid', _('Grid'))
		item.updateWidget()
		gridCheck = item._widget
		pack(hbox, gridCheck)
		gridCheck.item = item
		####
		colorItem = ColorPrefItem(ui, 'wcalGridColor', True)
		colorItem.updateWidget()
		pack(hbox, colorItem._widget)
		gridCheck.colorb = colorItem._widget
		gridCheck.connect('clicked', self.gridCheckClicked)
		colorItem._widget.item = colorItem
		colorItem._widget.connect('color-set', self.gridColorChanged)
		colorItem._widget.set_sensitive(ui.wcalGrid)
		####
		pack(self.optionsWidget, hbox)
		###
		self.optionsWidget.show_all()
Example #10
0
 def __init__(self, module, opt):
     t = opt[1]
     self.opt = opt  ## needed??
     self.module = module
     self.type = t
     self.var_name = opt[0]
     hbox = gtk.HBox()
     if t == bool:
         w = gtk.CheckButton(_(opt[2]))
         self.get_value = w.get_active
         self.set_value = w.set_active
     elif t == list:
         pack(hbox, gtk.Label(_(opt[2])))
         w = gtk.ComboBoxText()  ### or RadioButton
         for s in opt[3]:
             w.append_text(_(s))
         self.get_value = w.get_active
         self.set_value = w.set_active
     elif t == int:
         pack(hbox, gtk.Label(_(opt[2])))
         w = IntSpinButton(opt[3], opt[4])
         self.get_value = w.get_value
         self.set_value = w.set_value
     elif t == float:
         pack(hbox, gtk.Label(_(opt[2])))
         w = FloatSpinButton(opt[3], opt[4], opt[5])
         self.get_value = w.get_value
         self.set_value = w.set_value
     else:
         raise RuntimeError('bad option type "%s"' % t)
     pack(hbox, w)
     self._widget = hbox
     ####
     self.updateVar = lambda: setattr(self.module, self.var_name,
                                      self.get_value())
     self.updateWidget = lambda: self.set_value(
         getattr(self.module, self.var_name))
Example #11
0
def getFloatWidget():
	from scal3.ui_gtk.mywidgets.multi_spin.float_num import FloatSpinButton
	btn = FloatSpinButton(-3.3, 5.5, 1)
	btn.set_value(3.67)
	btn.set_editable(True)
	return btn