I can't find any good information on how to place a combobox inside a cell in a wxgrid. I tried Google, but maybe I'm blind. Anyone have a simple sample to share?
Take a look at GridChoiceCellEditor. You can use it as follows:
choice_editor = wx.grid.GridCellChoiceEditor(choices_list, True)
grid.SetCellEditor(row, col, choice_editor)
The wxPython demo has an example that shows how this is done in the GridStdEdRend.py file itself or from within the demo itself, see the "Editors and Renderers Demo" part of the grid demo. What you're looking for is the GridCellChoiceEditor. See also: http://wiki.wxpython.org/GridCellChoiceEditor
Related
From here:
# [START list_instances]
def list_instances(compute, project, zone):
result = compute.instances().list(project=project, zone=zone).execute()
return result['items'] if 'items' in result else None
# [END list_instances]
Can anyone tell me what these are for? They look like editor hints, or perhaps some auto-documentation thing, but I was not able to find information about it.
Looks like "user2357112 supports Monica" has the correct answer - the (Google-internal) documentation system seems to use these section boundaries to extract relevant code samples into the documentation.
I am trying to use an existing template design of powerpoint using python-pptx library. My problem is that I have two or more different templates ready and when I viewed their slide master, the "title and content layout" of each template are not on the same order. So, the index that I will use will be 1 if I used the first templates and 2 for the second templates.
Using the python-pptx library:
Sample Python Code 1 for fist templates
bullet_slide_layout = self.prs.slide_layouts[1]
Sample Python Code 2 for second templates
bullet_slide_layout = self.prs.slide_layouts[2]
Both of them works, but I do not want to change the indices every now and then whenever a new template design is added.
Please help. Also, If I am not clear with the problem I presented, please tell me. Thank you
If you want to retrieve a slide layout by something other than its position in the layout sequence, you will have to write something of your own.
There are a few approaches:
Use the slide layout name
Use the slide layout id
Characterize the slide by the number and type of placeholders it contains and perhaps their size and position.
So as an example, something simple would be:
def get_layout_by_name(prs, layout_name):
for layout in prs.slide_layouts:
if layout.name == layout_name:
return layout
return None
I started working with doxygen to generate the documentation of my Python code.
I use doxypy filter to preprocess the Python docstrings.
My goal is to have a nice syntax highlighting of doxygen comments in Python.
When writing my mainpage in a dedicated .dox file, I found that the doxygen comments can be highlighted in vim with the following command:
set syntax=c.doxygen
I tried the same command for Python but I got nothing:
set syntax=python.doxygen
I also made some googling and couldn't find anything interesting
Here is a typical piece of code I'd like to highlight:
class CompilationTab:
"""
The compilation tab of the verif GUI. It contains the layout description
and the functions required to deal with specific behaviors of the tab
"""
def __init__(self, notebook, tab_name):
"""
The class constructor.
#param notebook Notebook: The parent #c Notebook widget
#param tab_name String: The display name of the tab
"""
Does anybody already fixed this issue?
Thank you for help!
If you look into syntax/doxygen.vim you can read in the preamble of the file that currently only
cpp, c, idl, doxygen and php
files are supported.
Since doxygen.vim works a lot with the syn region command i searched for the line that defines the multiline string in syntax/python.vim.
The interesting part of the command that defines this region is
syn region pythonString start=+[uU]\=\z('''\|"""\)+ end="\z1" keepend
Derived from that what is in doxygen.vim and the above line you can add the following lines
"delete the following line if you don't want to have enhanced colors
let g:doxygen_enhanced_color=1
runtime! syntax/doxygen.vim
syn region doxygenComment matchgroup=pythonString start=+[uU]\=\z('''\|"""\)+ end="\z1" contains=doxygenSyncStart,doxygenStart,doxygenTODO keepend fold containedin=pythonString
to ~/.vim/after/syntax/python.vim or execute them by hand.
In addition you may have to customize the colors of the added doxygen highlighting groups by hand. At least i would do so since the resulting look doesn't conform with my taste.
Perhaps the fold argument of the syn command is of special interest for you. If you set foldmethod to syntax you can fold and unfold the multiline comments. That seems to be useful if you could no longer stand the view of those colors and are to lazy to adjust them :)
without doxygen highlighting:
with doxygen highlighting and g:doxygen_enhanced_color == 1:
I have created a listctrl with some of the data in the listctrl are very long, and instead of showing all of the text it ends with .... For example Att PSSM_r1_0_T is [-10.179077,0.944198]|Att PSSM_r1_0_Y is.... How would i be able to make it so it shows all of the text. Something like
Att PSSM_r1_0_T is [-10.179077,0.944198]|Att PSSM_r1_0_Y is
[-4.820935,9.914433]|Att PSSM_r1_2_I is [-8.527803,1.953804]|Att PSSM_r1_2_K is [-12.083334,-0.183813]|Att PSSM_r1_2_V is
[-14.112536,5.857771]|1
As the text is very long I would prefer if it covered more than one line.
I don't think that is possible to do with a standard listctrl.
Try poking around at the UltimateListCtrl, being a full owner drawn listctrl it has the ability to change the way its looks far more than a standard listctrl.
just a simple question on a wx.TextCtrl element.
i have this text field where on an application, where the user can add a string on it.
i want a text field with a red text on it.
so i've generated this code:
self.hRepositoryTextfield = wx.TextCtrl(self.hPanel)
self.hRepositoryTextfield.SetDefaultStyle(wx.TextAttr(wx.RED))
if the user copy on this text field some string with applied font on it (for example a black coloured string, or a string with a particular font) the red color, anyway the default style is not respected.
i would like the style i decide for my wx.TextCtrl is always forced according my settings.
how can i do?
thank you in advance
axel
The SetForegroundColor might work on one OS and not on another. It depends on the native widget. I would set the TextCtrl's style flag to wx.TE_RICH. Check out the wxPython demo for an example. You can also use the StyledTextCtrl or FancyText of even the HTMLCtrl.
self.hRepositoryTextfield.SetForegroundColor(wx.RED)
that should work ....
i solved the problem in this way:
in the first part of the code it is defined my textfield style...
self.hRepositoryTextfield.SetStyle(0, len(self.hRepositoryTextfield.GetValue()), wx.TextAttr(wx.RED))
self.hRepositoryTextfield.SetFont(self.hFontLabel)
self.hRepositoryTextfield.Bind(wx.EVT_TEXT, self.forceDefaultStyle)
... then i bind every text change to my forcing-style function:
def forceDefaultStyle(self, event):
hEventObject = event.GetEventObject()
hEventObject.SetStyle(0, len(self.hRepositoryTextfield.GetValue()), wx.TextAttr(wx.RED))
hEventObject.SetFont(self.hFontLabel)
and it works!