本文整理汇总了Python中misc.wxstr函数的典型用法代码示例。如果您正苦于以下问题:Python wxstr函数的具体用法?Python wxstr怎么用?Python wxstr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wxstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_template
def save_template(data=None):
"""\
Returns an out file name and template description for saving a template
"""
dlg = templates_ui.TemplateInfoDialog(None, -1, "")
if data is not None:
dlg.template_name.SetValue(
misc.wxstr(os.path.basename(os.path.splitext(data.filename)[0])))
dlg.author.SetValue(misc.wxstr(data.author))
dlg.description.SetValue(misc.wxstr(data.description))
dlg.instructions.SetValue(misc.wxstr(data.instructions))
ret = None
retdata = Template()
if dlg.ShowModal() == wx.ID_OK:
ret = dlg.template_name.GetValue().strip()
retdata.author = dlg.author.GetValue()
retdata.description = dlg.description.GetValue()
retdata.instructions = dlg.instructions.GetValue()
if not ret:
wx.MessageBox(_("Can't save a template with an empty name"),
_("Error"), wx.OK|wx.ICON_ERROR)
dlg.Destroy()
name = ret
if ret:
d = os.path.join(config._get_appdatapath(), '.wxglade', 'templates')
if not os.path.exists(d):
try:
os.makedirs(d)
except (OSError, IOError), e:
print _("ERROR creating %s: %s") % (d, e)
return None, retdata
ret = os.path.join(d, ret + '.wgt')
示例2: write
def write( self, outfile, tabs ):
if self.write_always or ( self.is_active() and self.get_value() ):
if self.getter: value = misc.wxstr( self.getter() )
else: value = misc.wxstr( self.owner[self.name][0]() )
if value != 'None':
fwrite = outfile.write
fwrite( ' ' * tabs + '<%s>' % self.name )
fwrite( escape( _encode( value ) ) )
fwrite( '</%s>\n' % self.name )
示例3: createBrowseButton
def createBrowseButton( self):
"""Create the browse-button control"""
ID = wx.NewId()
button =wx.Button(self, ID, misc.wxstr(self.buttonText))
button.SetToolTipString(misc.wxstr(self.toolTip))
w = button.GetTextExtent(self.buttonText)[0] + 10
button.SetMinSize((w, -1))
wx.EVT_BUTTON(button, ID, self.OnBrowse)
return button
示例4: write
def write(self, outfile, tabs):
if self.write_always or self.get_value():
if self.getter:
value = misc.wxstr(self.getter())
else:
value = misc.wxstr(self.owner[self.name][0]())
if value != "None":
fwrite = outfile.write
fwrite(" " * tabs + "<%s>" % self.name)
fwrite(escape(_encode(value)))
fwrite("</%s>\n" % self.name)
示例5: set_value
def set_value(self, value):
value = misc.wxstr(value)
if not misc.streq(value, self.value):
self.value = value
if self.style & wx.TE_MULTILINE:
value = value.replace('\\n', '\n')
if self.widget: self.widget.SetValue(value)
示例6: _move_item_right
def _move_item_right(self, index):
if index > 0 and (self.item_level(index) <= self.item_level(index-1)):
label = self.menu_items.GetItem(index, 0).m_text
self.menu_items.SetStringItem(index, 0, misc.wxstr(" " * 4)
+ label)
self.menu_items.SetItemState(index, wx.LIST_STATE_SELECTED, \
wx.LIST_STATE_SELECTED)
示例7: load_history
def load_history():
"""\
Loads the file history and returns a list of paths
"""
if 'WXGLADE_CONFIG_PATH' in os.environ:
path = os.path.expandvars('$WXGLADE_CONFIG_PATH')
else:
path = _get_appdatapath()
if path != common.wxglade_path:
path = os.path.join(path, '.wxglade')
try:
history = open(os.path.join(path, 'file_history.txt'))
l = history.readlines()
if l and l[0].startswith('# -*- coding:'):
try:
encoding = 'utf-8'
#l = [common._encode_from_xml(e, encoding) for e in l[1:]]
l = [e.decode(encoding) for e in l[1:]]
except Exception, e:
print _("ERR:"), e
l = l[1:]
history.close()
if common.use_gui:
l = [misc.wxstr(e, 'utf-8') for e in l]
return l
示例8: kde_file_selector
def kde_file_selector(message, default_path="", default_filename="",
default_extension="", wildcard="*.*", flags=0,
*args, **kwds):
"""\
Pops up the standard KDE file selector box, calling kdialog. The API is
identical to that of wx.FileSelector. If kdialog can't be invoked,
reverts to the standard wx.FileSelector. Note that at the moment not all
the arguments are meaningful (for example, parent and initial position are
ignored), and multiple selections are not supported.
"""
if not _kdialog_ok:
return wx.FileSelector(message, default_path, default_filename,
default_extension, wildcard, flags,
*args, **kwds)
r, w = os.pipe()
handler = _SigChldHandler()
oldhandler = signal.signal(signal.SIGCHLD, handler)
pid = os.fork()
if pid == 0:
os.close(r)
os.dup2(w, sys.stdout.fileno())
os.close(w)
startdir = default_path
if default_filename:
if not os.path.isdir(startdir):
startdir = os.path.dirname(startdir)
startdir = os.path.join(startdir, default_filename)
if flags & wx.SAVE:
kind = '--getsavefilename'
else:
kind = '--getopenfilename'
os.execlp('kdialog', 'kdialog', kind, startdir,
_wx_to_kde_wildcard(wildcard), '--title', message)
elif pid > 0:
disabler = wx.WindowDisabler()
app = wx.GetApp()
os.close(w)
while not handler.done:
app.Dispatch()
if handler.status != 0:
os.close(r)
return ""
filename = os.fdopen(r).readline().strip()
signal.signal(signal.SIGCHLD, oldhandler or signal.SIG_DFL)
if (flags & wx.SAVE) and (flags & wx.OVERWRITE_PROMPT) and \
os.path.exists(filename):
if wx.MessageBox(_("File '%s' already exists: do you really want "
"to overwrite it?") % misc.wxstr(filename),
_("Confirm"),
style=wx.YES_NO|wx.ICON_QUESTION) == wx.NO:
return kde_file_selector(message, default_path,
default_filename, default_extension,
wildcard, flags)
return filename
else:
raise OSError, _("Fork Error")
示例9: display
def display( self, parent ):
"""\
Actually builds the panel (with the text ctrl and the button to display
the dialog) to set the value of the property interactively
"""
self.id = wx.NewId()
val = misc.wxstr( self.owner[self.name][0]() )
label = wxGenStaticText( parent, -1, _mangle( self.dispName ),
size = ( _label_initial_width, -1 ) )
label.SetToolTip( wx.ToolTip( _mangle( self.dispName ) ) )
self.text = wx.TextCtrl( parent, self.id, val, size = ( 1, -1 ) )
self.btn = wx.Button( parent, self.id + 1, " ... ",
size = ( _label_initial_width, -1 ) )
enabler = None
if self.can_disable:
enabler = wx.CheckBox( parent, self.id + 1, '', size = ( 1, -1 ) )
wx.EVT_CHECKBOX( enabler, self.id + 1,
lambda event: self.toggle_active( event.IsChecked() ) )
self.prepare_activator( enabler, self.text )
if self.can_disable:
self.btn.Enable( self.is_active() )
wx.EVT_BUTTON( self.btn, self.id + 1, self.display_dialog )
sizer = wx.BoxSizer( wx.HORIZONTAL )
sizer.Add( label, 2, wx.ALL | wx.ALIGN_CENTER, 3 )
if getattr( self, '_enabler', None ) is not None:
sizer.Add( self._enabler, 1, wx.ALL | wx.ALIGN_CENTER, 3 )
option = 3
else:
option = 4
sizer.Add( self.text, option, wx.ALL | wx.ALIGN_CENTER, 3 )
sizer.Add( self.btn, 1, wx.ALL | wx.ALIGN_CENTER, 3 )
self.panel = sizer
self.bind_event( self.on_change_val )
wx.EVT_CHAR( self.text, self.on_char )
示例10: add
def add(node, index):
label = get(index, 0).lstrip()
id = get(index, 1)
name = get(index, 2)
help_str = get(index, 3)
event_handler = get(index, 5)
try:
item_type = int(get(index, 4))
except ValueError:
item_type = 0
checkable = item_type == 1 and misc.wxstr("1") or misc.wxstr("")
radio = item_type == 2 and misc.wxstr("1") or misc.wxstr("")
n = MenuTree.Node(label, id, name, help_str, checkable, radio,
handler=event_handler)
node.children.append(n)
n.parent = node
return n
示例11: set_value
def set_value( self, value ):
value = misc.wxstr( value )
if self.multiline:
self.val = value.replace( '\n', '\\n' )
value = value.replace( '\\n', '\n' )
else: self.val = value
try: self.text.SetValue( value )
except AttributeError: pass
示例12: set_label
def set_label(self, value):
value = misc.wxstr(value)
if not misc.streq(value, self.label):
self.label = value
if self.widget:
self.widget.SetLabel(value.replace("\\n", "\n"))
if not self.properties["size"].is_active():
self.sizer.set_item(self.pos, size=self.widget.GetBestSize())
示例13: set_choices
def set_choices(self, values):
self.choices = [ misc.wxstr(v[0]) for v in values ]
self.properties['selection'].set_range(0, len(self.choices)-1)
if self.widget:
self.widget.Clear()
for c in self.choices: self.widget.Append(c)
if not self.properties['size'].is_active():
self.sizer.set_item(self.pos, size=self.widget.GetBestSize())
示例14: set_label
def set_label(self, value):
value = misc.wxstr(value)
if not misc.streq(value, self.label):
self.label = value
if self.static_box:
self.static_box.SetLabel(value)
if not self.properties['size'].is_active():
self.sizer.set_item(self.pos,
size=self.widget.GetBestSize())
示例15: add
def add(tool):
i = index[0]
add_item(i, misc.wxstr(tool.label))
set_item(i, 1, misc.wxstr(tool.id))
set_item(i, 2, misc.wxstr(tool.bitmap1))
set_item(i, 3, misc.wxstr(tool.bitmap2))
set_item(i, 4, misc.wxstr(tool.short_help))
set_item(i, 5, misc.wxstr(tool.long_help))
set_item(i, 7, misc.wxstr(tool.handler))
item_type = 0
set_item(i, 6, misc.wxstr(tool.type))
index[0] += 1