本文整理汇总了Python中src.sysvars.is_gtk函数的典型用法代码示例。如果您正苦于以下问题:Python is_gtk函数的具体用法?Python is_gtk怎么用?Python is_gtk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_gtk函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_cursor
def set_cursor(self, value):
"""Changes the grid cursor cell.
Parameters
----------
value: 2-tuple or 3-tuple of String
\trow, col, tab or row, col for target cursor position
"""
if len(value) == 3:
self.grid._last_selected_cell = row, col, tab = value
if tab != self.cursor[2]:
post_command_event(self.main_window,
self.GridActionTableSwitchMsg, newtable=tab)
if is_gtk():
wx.Yield()
else:
row, col = value
self.grid._last_selected_cell = row, col, self.grid.current_table
if not (row is None and col is None):
self.grid.MakeCellVisible(row, col)
self.grid.SetGridCursor(row, col)
示例2: progress_status
def progress_status(self):
"""Displays progress in statusbar"""
if self.line % self.freq == 0:
text = self.statustext.format(nele=self.line,
totalele=self.total_lines)
if self.main_window.grid.actions.pasting:
try:
post_command_event(self.main_window,
self.main_window.StatusBarMsg,
text=text)
except TypeError:
# The main window does not exist any more
pass
else:
# Write directly to the status bar because the event queue
# is not emptied during file access
self.main_window.GetStatusBar().SetStatusText(text)
# Now wait for the statusbar update to be written on screen
if is_gtk():
try:
wx.Yield()
except:
pass
self.line += 1
示例3: __init__
def __init__(self, parent, main_window, *args, **kwargs):
wx.Panel.__init__(self, parent, *args, **kwargs)
try:
self.SetBackgroundColour(get_color(wx.SYS_COLOUR_FRAMEBK))
except AttributeError:
# Does not work on wx 2.x
pass
self.parent = parent
self.main_window = main_window
style = wx.TE_PROCESS_ENTER | wx.TE_MULTILINE
self.entry_line = EntryLine(self, main_window, style=style)
self.selection_toggle_button = \
wx.ToggleButton(self, -1, size=(24, -1), label=u"\u25F0")
tooltip = wx.ToolTip(_("Toggles link insertion mode."))
self.selection_toggle_button.SetToolTip(tooltip)
self.selection_toggle_button.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle)
if not is_gtk():
# TODO: Selections still do not work right on Windows
self.selection_toggle_button.Disable()
self.__do_layout()
示例4: OnOpen
def OnOpen(self, event):
"""File open event handler"""
# If changes have taken place save of old grid
if self.main_window.changed_since_save:
save_choice = self.interfaces.get_save_request_from_user()
if save_choice is None:
# Cancelled close operation
return
elif save_choice:
# User wants to save content
post_command_event(self.main_window, self.main_window.SaveMsg)
# Get filepath from user
wildcard = \
_("Pyspread file") + " (*.pys)|*.pys|" + \
_("All files") + " (*.*)|*.*"
message = _("Choose pyspread file to open.")
style = wx.OPEN | wx.CHANGE_DIR
filepath, filterindex = \
self.interfaces.get_filepath_findex_from_user(wildcard, message,
style)
if filepath is None:
return
# Change the main window filepath state
self.main_window.filepath = filepath
# Load file into grid
post_command_event(self.main_window,
self.main_window.GridActionOpenMsg,
attr={"filepath": filepath})
# Set Window title to new filepath
title_text = filepath.split("/")[-1] + " - pyspread"
post_command_event(self.main_window,
self.main_window.TitleMsg, text=title_text)
self.main_window.grid.ForceRefresh()
if is_gtk():
wx.Yield()
# Mark content as unchanged
try:
post_command_event(self.main_window, self.ContentChangedMsg,
changed=False)
except TypeError:
# The main window does not exist any more
pass
示例5: _is_aborted
def _is_aborted(self, cycle, statustext, total_elements=None, freq=None):
"""Displays progress and returns True if abort
Parameters
----------
cycle: Integer
\tThe current operation cycle
statustext: String
\tLeft text in statusbar to be displayed
total_elements: Integer:
\tThe number of elements that have to be processed
freq: Integer, defaults to None
\tNo. operations between two abort possibilities, 1000 if None
"""
if total_elements is None:
statustext += _("{nele} elements processed. Press <Esc> to abort.")
else:
statustext += _("{nele} of {totalele} elements processed. "
"Press <Esc> to abort.")
if freq is None:
show_msg = False
freq = 1000
else:
show_msg = True
# Show progress in statusbar each freq (1000) cells
if cycle % freq == 0:
if show_msg:
text = statustext.format(nele=cycle, totalele=total_elements)
try:
post_command_event(self.main_window, self.StatusBarMsg,
text=text)
except TypeError:
# The main window does not exist any more
pass
# Now wait for the statusbar update to be written on screen
if is_gtk():
try:
wx.Yield()
except:
pass
# Abort if we have to
if self.need_abort:
# We have to abort`
return True
# Continue
return False
示例6: OnCellTextRotation
def OnCellTextRotation(self, event):
"""Cell text rotation event handler"""
self.grid.actions.set_attr("angle", event.angle, mark_unredo=True)
self.grid.ForceRefresh()
self.grid.update_attribute_toolbar()
if is_gtk():
wx.Yield()
event.Skip()
示例7: OnInt
def OnInt(self, event):
"""IntCtrl event method that updates the current table"""
self.SetMax(self.no_tabs - 1)
if event.GetValue() > self.GetMax():
self.SetValue(self.GetMax())
return
if not self.switching:
self.switching = True
post_command_event(self, self.GridActionTableSwitchMsg, newtable=event.GetValue())
if is_gtk():
wx.Yield()
self.switching = False
示例8: OnCellTextRotation
def OnCellTextRotation(self, event):
"""Cell text rotation event handler"""
self.grid.actions.toggle_attr("angle")
self.grid.ForceRefresh()
self.grid.update_attribute_toolbar()
if is_gtk():
try:
wx.Yield()
except:
pass
event.Skip()
示例9: OnGridSelection
def OnGridSelection(self, event):
"""Event handler for grid selection in selection mode adds text"""
current_table = copy(self.main_window.grid.current_table)
post_command_event(self, self.GridActionTableSwitchMsg, newtable=self.last_table)
if is_gtk():
wx.Yield()
sel_start, sel_stop = self.last_selection
shape = self.main_window.grid.code_array.shape
selection_string = event.selection.get_access_string(shape, current_table)
self.Replace(sel_start, sel_stop, selection_string)
self.last_selection = sel_start, sel_start + len(selection_string)
post_command_event(self, self.GridActionTableSwitchMsg, newtable=current_table)
示例10: __init__
def __init__(self, parent, main_window, *args, **kwargs):
wx.Panel.__init__(self, parent, *args, **kwargs)
self.parent = parent
self.main_window = main_window
style = wx.TE_PROCESS_ENTER | wx.TE_MULTILINE
self.entry_line = EntryLine(self, main_window, style=style)
self.selection_toggle_button = wx.ToggleButton(self, -1, size=(24, -1), label=u"\u25F0")
tooltip = wx.ToolTip(_("Toggles link insertion mode."))
self.selection_toggle_button.SetToolTip(tooltip)
self.selection_toggle_button.Bind(wx.EVT_TOGGLEBUTTON, self.OnToggle)
if not is_gtk():
# TODO: Selections still do not work right on Windows
self.selection_toggle_button.Disable()
self.__do_layout()
示例11: progress_status
def progress_status(self):
"""Displays progress in statusbar"""
if self.line % self.freq == 0:
text = self.statustext.format(nele=self.line,
totalele=self.total_lines)
try:
post_command_event(self.main_window,
self.main_window.StatusBarMsg, text=text)
except TypeError:
# The main window does not exist any more
pass
# Now wait for the statusbar update to be written on screen
if is_gtk():
wx.Yield()
self.line += 1
示例12: OnFontDialog
def OnFontDialog(self, event):
"""Event handler for launching font dialog"""
# Get current font data from current cell
cursor = self.main_window.grid.actions.cursor
attr = self.main_window.grid.code_array.cell_attributes[cursor]
size, style, weight, font = \
[attr[name] for name in ["pointsize", "fontstyle", "fontweight",
"textfont"]]
current_font = wx.Font(int(size), -1, style, weight, 0, font)
# Get Font from dialog
fontdata = wx.FontData()
fontdata.EnableEffects(True)
fontdata.SetInitialFont(current_font)
dlg = wx.FontDialog(self.main_window, fontdata)
if dlg.ShowModal() == wx.ID_OK:
fontdata = dlg.GetFontData()
font = fontdata.GetChosenFont()
post_command_event(self.main_window, self.main_window.FontMsg,
font=font.FaceName)
post_command_event(self.main_window, self.main_window.FontSizeMsg,
size=font.GetPointSize())
post_command_event(self.main_window, self.main_window.FontBoldMsg,
weight=font.GetWeightString())
post_command_event(self.main_window,
self.main_window.FontItalicsMsg,
style=font.GetStyleString())
if is_gtk():
try:
wx.Yield()
except:
pass
self.main_window.grid.update_attribute_toolbar()
示例13: set_cursor
def set_cursor(self, value):
"""Changes the grid cursor cell.
Parameters
----------
value: 2-tuple or 3-tuple of String
\trow, col, tab or row, col for target cursor position
"""
shape = self.grid.code_array.shape
if len(value) == 3:
self.grid._last_selected_cell = row, col, tab = value
if row < 0 or col < 0 or tab < 0 or \
row >= shape[0] or col >= shape[1] or tab >= shape[2]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
if tab != self.cursor[2]:
post_command_event(self.main_window,
self.GridActionTableSwitchMsg, newtable=tab)
if is_gtk():
try:
wx.Yield()
except:
pass
else:
row, col = value
if row < 0 or col < 0 or row >= shape[0] or col >= shape[1]:
raise ValueError("Cell {value} outside of {shape}".format(
value=value, shape=shape))
self.grid._last_selected_cell = row, col, self.grid.current_table
if not (row is None and col is None):
self.grid.MakeCellVisible(row, col)
self.grid.SetGridCursor(row, col)
示例14: OnDrawItem
def OnDrawItem(self, dc, rect, item, flags):
if item == wx.NOT_FOUND:
return
__rect = wx.Rect(*rect) # make a copy
__rect.Deflate(3, 5)
font_string = self.GetString(item)
font = get_default_font()
font.SetFaceName(font_string)
if not is_gtk():
# Do not display fonts in font coice box for Windows
font.SetFamily(wx.FONTFAMILY_SWISS)
dc.SetFont(font)
text_width, text_height = dc.GetTextExtent(font_string)
text_x = __rect.x
text_y = __rect.y + int((__rect.height - text_height) / 2.0)
# Draw the example text in the combobox
dc.DrawText(font_string, text_x, text_y)
示例15: OnNew
def OnNew(self, event):
"""New grid event handler"""
# If changes have taken place save of old grid
if self.main_window.changed_since_save:
save_choice = self.interfaces.get_save_request_from_user()
if save_choice is None:
# Cancelled close operation
return
elif save_choice:
# User wants to save content
post_command_event(self.main_window, self.main_window.SaveMsg)
# Get grid dimensions
shape = self.interfaces.get_dimensions_from_user(no_dim=3)
if shape is None:
return
# Set new filepath and post it to the title bar
self.main_window.filepath = None
post_command_event(self.main_window, self.main_window.TitleMsg,
text="pyspread")
# Clear globals
self.main_window.grid.actions.clear_globals_reload_modules()
# Create new grid
post_command_event(self.main_window, self.main_window.GridActionNewMsg,
shape=shape)
# Update TableChoiceIntCtrl
post_command_event(self.main_window, self.main_window.ResizeGridMsg,
shape=shape)
if is_gtk():
wx.Yield()
self.main_window.grid.actions.change_grid_shape(shape)
self.main_window.grid.GetTable().ResetView()
self.main_window.grid.ForceRefresh()
# Display grid creation in status bar
msg = _("New grid with dimensions {dim} created.").format(dim=shape)
post_command_event(self.main_window, self.main_window.StatusBarMsg,
text=msg)
self.main_window.grid.ForceRefresh()
if is_gtk():
wx.Yield()
# Mark content as unchanged
try:
post_command_event(self.main_window, self.ContentChangedMsg,
changed=False)
except TypeError:
# The main window does not exist any more
pass