本文整理汇总了Python中wx.SpinCtrl方法的典型用法代码示例。如果您正苦于以下问题:Python wx.SpinCtrl方法的具体用法?Python wx.SpinCtrl怎么用?Python wx.SpinCtrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.SpinCtrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addStaticBoxWithLabels
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def addStaticBoxWithLabels(self):
boxSizerH = wx.BoxSizer(wx.HORIZONTAL)
staticBox = wx.StaticBox( self.panel, -1, "Labels within a Frame" )
staticBoxSizerV = wx.StaticBoxSizer( staticBox, wx.VERTICAL )
boxSizerV = wx.BoxSizer( wx.VERTICAL )
staticText1 = wx.StaticText( self.panel, -1, " Choose a number:" )
boxSizerV.Add( staticText1, 0, wx.ALL)
staticText2 = wx.StaticText( self.panel, -1, " Label 2")
boxSizerV.Add( staticText2, 0, wx.ALL )
#------------------------------------------------------
staticBoxSizerV.Add( boxSizerV, 0, wx.ALL )
boxSizerH.Add(staticBoxSizerV)
#------------------------------------------------------
boxSizerH.Add(wx.ComboBox(self.panel, size=(70, -1)))
#------------------------------------------------------
boxSizerH.Add(wx.SpinCtrl(self.panel, size=(50, -1), style=wx.BORDER_RAISED))
# Add local boxSizer to main frame
self.statBoxSizerV.Add( boxSizerH, 1, wx.ALL )
#----------------------------------------------------------
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:23,代码来源:GUI_wxPython.py
示例2: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.label_2_copy = wx.StaticText(self, -1, _("Family:"))
self.label_3_copy = wx.StaticText(self, -1, _("Style:"))
self.label_4_copy = wx.StaticText(self, -1, _("Weight:"))
self.family = wx.Choice(self, -1, choices=["Default", "Decorative", "Roman", "Script", "Swiss", "Modern"])
self.style = wx.Choice(self, -1, choices=["Normal", "Slant", "Italic"])
self.weight = wx.Choice(self, -1, choices=["Normal", "Light", "Bold"])
self.label_1 = wx.StaticText(self, -1, _("Size in points:"))
self.point_size = wx.SpinCtrl(self, -1, "", min=0, max=100)
self.underline = wx.CheckBox(self, -1, _("Underlined"))
self.font_btn = wx.Button(self, -1, _("Specific font..."))
self.static_line_1 = wx.StaticLine(self, -1)
self.ok_btn = wx.Button(self, wx.ID_OK, _("OK"))
self.cancel_btn = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
self.__set_properties()
self.__do_layout()
self.value = None
self.font_btn.Bind(wx.EVT_BUTTON, self.choose_specific_font)
self.ok_btn.Bind(wx.EVT_BUTTON, self.on_ok)
示例3: ClearHighlights
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def ClearHighlights(self, highlight_type=None):
if highlight_type is None:
self.Highlights = []
else:
self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type]
for control in self.HighlightControls.itervalues():
if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
control.SetBackgroundColour(wx.NullColour)
control.SetForegroundColour(wx.NullColour)
elif isinstance(control, wx.TextCtrl):
value = control.GetValueStr() if isinstance(control, CustomIntCtrl) else \
control.GetValue()
control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour))
elif isinstance(control, wx.gizmos.EditableListBox):
listctrl = control.GetListCtrl()
for i in xrange(listctrl.GetItemCount()):
listctrl.SetItemBackgroundColour(i, wx.NullColour)
listctrl.SetItemTextColour(i, wx.NullColour)
self.StructureElementsTable.ClearHighlights(highlight_type)
self.RefreshView()
示例4: ShowHighlights
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def ShowHighlights(self):
type_infos = self.Controler.GetDataTypeInfos(self.TagName)
for infos, start, end, highlight_type in self.Highlights:
if infos[0] == "struct":
self.StructureElementsTable.AddHighlight(infos[1:], highlight_type)
else:
control = self.HighlightControls.get((type_infos["type"], infos[0]), None)
if control is not None:
if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
control.SetBackgroundColour(highlight_type[0])
control.SetForegroundColour(highlight_type[1])
elif isinstance(control, wx.TextCtrl):
control.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0]))
elif isinstance(control, wx.gizmos.EditableListBox):
listctrl = control.GetListCtrl()
listctrl.SetItemBackgroundColour(infos[1], highlight_type[0])
listctrl.SetItemTextColour(infos[1], highlight_type[1])
listctrl.Select(listctrl.FocusedItem, False)
示例5: addSpin
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def addSpin(self, name, descr, parent, sizer, cfgName):
sizer.Add(wx.StaticText(parent, -1, descr), 0,
wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 10)
entry = wx.SpinCtrl(parent, -1)
entry.SetRange(*self.cfg.cvars.getMinMax(cfgName))
wx.EVT_SPINCTRL(self, entry.GetId(), self.OnMisc)
wx.EVT_KILL_FOCUS(entry, self.OnKillFocus)
sizer.Add(entry, 0)
setattr(self, name + "Entry", entry)
示例6: crt_spinctrl
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def crt_spinctrl(self, spin_range=(0, 9999)):
spinctrl = wx.SpinCtrl(self, size=self.SPINCTRL_SIZE)
spinctrl.SetRange(*spin_range)
return spinctrl
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def __init__(self, *args, **kwargs):
if gtk3:
if 'size' in kwargs:
kwargs['size'] = wx.Size(max(self.gtk3MinSize, kwargs['size'][0]), kwargs['size'][1])
else:
kwargs['size'] = wx.Size(self.gtk3MinSize, -1)
wx.SpinCtrl.__init__(self, *args, **kwargs)
示例8: SetToolTip
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def SetToolTip(self, tip):
if wxPythonPhoenix:
wx.SpinCtrl.SetToolTip(self, tipString=tip)
else:
wx.SpinCtrl.SetToolTipString(self, tip)
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def __init__(self, parent, name):
PPanel.__init__(self, parent, name)
self.ID_SPIN_CTRL = wx.NewId()
sizer = wx.BoxSizer()
self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1))
self.spin.SetRange(-2147483648, 2147483647) # min/max integers
sizer.Add(self.spin)
self.SetAutoLayout(True)
self.SetSizerAndFit(sizer)
wx.EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange)
示例10: create_spin_ctrl
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def create_spin_ctrl(self, panel):
style = wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS
spin = wx.SpinCtrl( panel, -1, style=style, min=self.val_range[0], max=self.val_range[1] )
val = self.value
if not val: spin.SetValue(1) # needed for GTK to display a '0'
spin.SetValue(val)
spin.SetSelection(-1,-1)
return spin
示例11: _create_spin_ctrl
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def _create_spin_ctrl(self, panel):
style = wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS
self.spin = wx.SpinCtrl( panel, -1, style=style, min=self.val_range[0], max=self.val_range[1] )
val = self.value
if not val: self.spin.SetValue(1) # needed for GTK to display a '0'
self.spin.SetValue(val)
示例12: create_editor
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def create_editor(self, panel, sizer):
if not _is_gridbag(self.owner.parent): return
max_rows, max_cols = self.owner.parent.check_span_range(self.owner.index, *self.value)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
# label
self.label_ctrl = label = self._get_label(self._find_label(), panel)
hsizer.Add(label, 0, wx.ALL | wx.ALIGN_CENTER, 3)
# checkbox, if applicable
self.enabler = None
style = wx.TE_PROCESS_ENTER | wx.SP_ARROW_KEYS
self.rowspin = wx.SpinCtrl( panel, -1, style=style, min=1, max=max_rows) # don't set size here as the
self.colspin = wx.SpinCtrl( panel, -1, style=style, min=1, max=max_cols) # combination withe SetSelection fails
val = self.value
self.rowspin.SetValue(val and val[0] or 1)
self.colspin.SetValue(val and val[1] or 1)
self.rowspin.Enable(max_rows!=1)
self.colspin.Enable(max_cols!=1)
self.rowspin.SetSelection(-1, -1)
self.colspin.SetSelection(-1, -1)
# layout of the controls / sizers; when adding the spins, set min size as well
hsizer.Add(wx.StaticText(panel, -1, _("Rows:")), 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3)
si = hsizer.Add(self.rowspin, 5, wx.ALL | wx.ALIGN_CENTER, 3).SetMinSize( (30,-1) )
hsizer.Add(wx.StaticText(panel, -1, _("Cols:")), 1, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3)
hsizer.Add(self.colspin, 5, wx.ALL | wx.ALIGN_CENTER, 3).SetMinSize( (30,-1) )
sizer.Add(hsizer, 0, wx.EXPAND)
self._set_tooltip(label, self.rowspin, self.colspin)
self.rowspin.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus) # by default, the value is only set when the focus is lost
self.colspin.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
self.rowspin.Bind(wx.EVT_SET_FOCUS, self.on_focus)
self.colspin.Bind(wx.EVT_SET_FOCUS, self.on_focus)
if self.immediate:
self.rowspin.Bind(wx.EVT_SPINCTRL, self.on_spin)
self.rowspin.Bind(wx.EVT_TEXT_ENTER, self.on_spin) # we want the enter key (see style above)
self.colspin.Bind(wx.EVT_SPINCTRL, self.on_spin)
self.colspin.Bind(wx.EVT_TEXT_ENTER, self.on_spin)
self.editing = True
示例13: create_widget
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def create_widget(self):
mi,ma = self.properties["range"].get_tuple()
if self.properties["value"].is_active():
self.widget = wx.SpinCtrl(self.parent_window.widget, self.id, min=mi, max=ma, initial=self.value)
else:
self.widget = wx.SpinCtrl(self.parent_window.widget, self.id, min=mi, max=ma)
示例14: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: ImageProperty.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP
wx.Frame.__init__(self, *args, **kwds)
Module.__init__(self)
self.SetSize((276, 218))
self.spin_step_size = wx.SpinCtrl(self, wx.ID_ANY, "1", min=1, max=63)
self.combo_dpi = wx.ComboBox(self, wx.ID_ANY,
choices=["1000", "500", "333", "250", "200", "166", "142", "125", "111", "100"],
style=wx.CB_DROPDOWN)
self.text_x = wx.TextCtrl(self, wx.ID_ANY, "")
self.text_y = wx.TextCtrl(self, wx.ID_ANY, "")
self.text_width = wx.TextCtrl(self, wx.ID_ANY, "")
self.text_height = wx.TextCtrl(self, wx.ID_ANY, "")
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_SPINCTRL, self.on_spin_step, self.spin_step_size)
self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_step, self.spin_step_size)
self.Bind(wx.EVT_COMBOBOX, self.on_combo_dpi, self.combo_dpi)
self.Bind(wx.EVT_TEXT, self.on_text_x, self.text_x)
self.Bind(wx.EVT_TEXT_ENTER, self.on_text_x, self.text_x)
self.Bind(wx.EVT_TEXT, self.on_text_y, self.text_y)
self.Bind(wx.EVT_TEXT_ENTER, self.on_text_y, self.text_y)
self.Bind(wx.EVT_TEXT, self.on_text_width, self.text_width)
self.Bind(wx.EVT_TEXT_ENTER, self.on_text_width, self.text_width)
self.Bind(wx.EVT_TEXT, self.on_text_height, self.text_height)
self.Bind(wx.EVT_TEXT_ENTER, self.on_text_height, self.text_height)
# end wxGlade
self.image_element = None
self.Bind(wx.EVT_CLOSE, self.on_close, self)
示例15: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import SpinCtrl [as 别名]
def __init__(self, *args, **kwds):
# begin wxGlade: RasterProperty.__init__
kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP
wx.Frame.__init__(self, *args, **kwds)
Module.__init__(self)
self.SetSize((359, 355))
self.spin_speed_set = wx.SpinCtrlDouble(self, wx.ID_ANY, "200.0", min=0.0, max=500.0)
self.spin_power_set = wx.SpinCtrlDouble(self, wx.ID_ANY, "1000.0", min=0.0, max=1000.0)
self.spin_step_size = wx.SpinCtrl(self, wx.ID_ANY, "1", min=0, max=63)
self.combo_raster_direction = wx.ComboBox(self, wx.ID_ANY, choices=[_("Top To Bottom"), _("Bottom To Top"), _("Right To Left"), _("Left To Right")], style=wx.CB_DROPDOWN)
self.spin_overscan_set = wx.SpinCtrlDouble(self, wx.ID_ANY, "20.0", min=0.0, max=1000.0)
self.radio_directional_raster = wx.RadioBox(self, wx.ID_ANY, _("Directional Raster"), choices=[_("Bidirectional"), _("Unidirectional")], majorDimension=2, style=wx.RA_SPECIFY_ROWS)
self.radio_corner = wx.RadioBox(self, wx.ID_ANY, _("Start Corner"), choices=[" ", " ", " ", " "], majorDimension=2, style=wx.RA_SPECIFY_ROWS)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_speed, self.spin_speed_set)
self.Bind(wx.EVT_TEXT, self.on_spin_speed, self.spin_speed_set)
self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_speed, self.spin_speed_set)
self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_power, self.spin_power_set)
self.Bind(wx.EVT_TEXT, self.on_spin_power, self.spin_power_set)
self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_power, self.spin_power_set)
self.Bind(wx.EVT_SPINCTRL, self.on_spin_step, self.spin_step_size)
self.Bind(wx.EVT_TEXT, self.on_spin_step, self.spin_step_size)
self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_step, self.spin_step_size)
self.Bind(wx.EVT_COMBOBOX, self.on_combo_raster_direction, self.combo_raster_direction)
self.Bind(wx.EVT_SPINCTRLDOUBLE, self.on_spin_overscan, self.spin_overscan_set)
self.Bind(wx.EVT_TEXT, self.on_spin_overscan, self.spin_overscan_set)
self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_overscan, self.spin_overscan_set)
self.Bind(wx.EVT_RADIOBOX, self.on_radio_directional, self.radio_directional_raster)
self.Bind(wx.EVT_RADIOBOX, self.on_radio_corner, self.radio_corner)
# end wxGlade
self.operation = None
self.Bind(wx.EVT_CLOSE, self.on_close, self)