TextCtrl and Events

Hello again.
So, now i have succesfully created my application mainFrame.
I wanted to do 2 things but i don't find how to do.

First: On mouse left click on a dirtreeCtrl i want to get the path. I tried EVT_MOUSE_EVENTS but it only works on "move".

I tried EVT_LEFT_CLICK but it doesn't work

Second, i want to drag-drop item from tree to my STC... But i don't find how to activate drag control on my dirtree. I found how to capture the DROP on my STC

Thanks

Metal3d wrote:

Hello again.
So, now i have succesfully created my application mainFrame.
I wanted to do 2 things but i don't find how to do.

First: On mouse left click on a dirtreeCtrl i want to get the path. I tried EVT_MOUSE_EVENTS but it only works on "move".

I tried EVT_LEFT_CLICK but it doesn't work

Second, i want to drag-drop item from tree to my STC... But i don't find how to activate drag control on my dirtree. I found how to capture the DROP on my STC

The wx.GenericDirCtrl window is almost entirely covered by the wx.TreeCtrl window that it is composed of, so that is why you don't get mouse events from it. You can however use GetTreeCtrl() to return the child treectrl and bind your event handlers to that window.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

Metal3d wrote:

Hello again.
So, now i have succesfully created my application mainFrame.
I wanted to do 2 things but i don't find how to do.

First: On mouse left click on a dirtreeCtrl i want to get the path. I tried EVT_MOUSE_EVENTS but it only works on "move".

I tried EVT_LEFT_CLICK but it doesn't work

Second, i want to drag-drop item from tree to my STC... But i don't find how to activate drag control on my dirtree. I found how to capture the DROP on my STC

The wx.GenericDirCtrl window is almost entirely covered by the wx.TreeCtrl window that it is composed of, so that is why you don't get mouse events from it. You can however use GetTreeCtrl() to return the child treectrl and bind your event handlers to that window.

I finally used EVT_TREE_SEL_CHANGED found by a "grep" on wx dir... :wink:

For the second question, i don't know how dng works. I found EVT_TREE_BEGIN_DRAG event to know that i'm dragging an item... but nothing proves me that i'm really dragging something, mouse appearence donesn't change. My Stc dosen't recieve the EVT_TREE_END_DRAG or EVT_STC_URIDROPPED etc... i have tried a lot of event... but never my STC capture the drop event...

My goal is to drag and drop a file from my DirTree and open this file in my STC (or a new tab).
Everything works excepting this functionnality :slight_smile:

Just a PS: wxPython is really great, to develop an application as i want to do i not really complicated. If i ask a lot of questions, this is because i'm relativelly novice in WX, not in Python :slight_smile: and i don't have every knowledges to develop my whole application alone now. Belive me, i read docs, manuals, and sample codes... my application is very functionnal yet.
Thanks for you help and excuse my english :wink:

Hi,

I've a wx.CheckBox with text that spans over multiple lines. Is it possible to align the text in such a manner that the checkbox itself is not centered compared to the text, but level with the first line? Like this...

[x] First line
     Second line
     Third line

What I get so far is a centered checkbox:

      First line
[x] Second line
      Third line

Any help much appreciated.

Cheers, Nick.

Nikolas Arend wrote:

Robin Dunn wrote:

Nikolas Arend wrote:

Hi again,

can I center the text in a wx.lib.dialogs.ScrolledMessageDialog()? I tried style=wx.TE_CENTRE, but that doesn't have any effect, the text is always left aligned.
Or which predefined dialog would be best suited for a simple 'About' dialog?

It depends on how simple is "simple" A lot of apps just use a wx.MessageDialog.

Fairly simple ;-), just text actually. But it should be scrollable also and I wouldn't like to have icons in the dialog. So, to come back to my first question, would it be possible to center the text in a wx.lib.dialogs.ScrolledMessageDialog()?

Not as it is now, but it's a very simple dialog (other than using the wacky Layoutf for the layout) so you can easily use it as a starting point to do whatever you want:

class ScrolledMessageDialog(wx.Dialog):
     def __init__(self, parent, msg, caption,
                  pos=wx.DefaultPosition, size=(500,300),
                  style=wx.DEFAULT_DIALOG_STYLE):
         wx.Dialog.__init__(self, parent, -1, caption, pos, size, style)
         x, y = pos
         if x == -1 and y == -1:
             self.CenterOnScreen(wx.BOTH)

         text = wx.TextCtrl(self, -1, msg,
                            style=wx.TE_MULTILINE | wx.TE_READONLY)

         ok = wx.Button(self, wx.ID_OK, "OK")
         ok.SetDefault()
         lc = layoutf.Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok))
         text.SetConstraints(lc)

         lc = layoutf.Layoutf('b=b5#1;x%w50#1;w!80;h*', (self,))
         ok.SetConstraints(lc)
         self.SetAutoLayout(1)
         self.Layout()

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!