473,386 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

wxPython: StaticText Event

Plaese look at this simple class.

import wx
class MyFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, "Hide test", size=(160,160))

# create widgets
self.pnl = wx.Panel(self)
self.st = wx.StaticText(self.pnl, -1,
"Static Text Control", pos=(30,20))
self.tc = wx.TextCtrl(self.pnl, -1, pos=(30,100))
self.Layout()

# Binding
self.st.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterStArea)
self.tc.Bind(wx.EVT_ENTER_WINDOW, self.OnEnterTcArea)

def OnEnterStArea(self, event):
print "Mouse entering in STATIC text control area"

def OnEnterTcArea(self, event):
print "Mouse entering in text control area"

app = wx.PySimpleApp()
frame = MyFrame(None, -1)
frame.Show()
app.MainLoop()
Hovering mouse over the StaticText Control should generate an
EVT_ENTER_WINDOW event like the TextCtrl Control, but it does not happen.

How can I make the StaticText event working?

thank you
David
Sep 7 '06 #1
4 4854
David a écrit :
Plaese look at this simple class.
(...code...)
Hovering mouse over the StaticText Control should generate an
EVT_ENTER_WINDOW event like the TextCtrl Control, but it does not happen.

How can I make the StaticText event working?
I quick Google search found the following thread:

http://lists.wxwidgets.org/archive/w.../msg31855.html
or
http://lists.wxwidgets.org/archive/w.../msg31983.html

It suggest that you use another kind of control instead.
Is a disabled TextCtrl acceptable?

Hope this helps,

--
Amaury
Sep 8 '06 #2
Hovering mouse over the StaticText Control should generate an
EVT_ENTER_WINDOW event like the TextCtrl Control, but it does not happen.

How can I make the StaticText event working?
According to the book "wxPython In Action", page 186:

"One feature that you cannot see from just the figure is that the
wx.StaticText window never receives or responds to mouse events, and
never takes the user focus."

If you want to create static text that responds to mouse events, try
using the wx.lib.stattext.GenStaticText class.

Add the following import:

import wx.lib.stattext

Then,

self.st = wx.lib.stattext.GenStaticText(self.pnl, -1, 'Static Text
Control', pos=(30,20))

Regards,

John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Sep 8 '06 #3
Il Fri, 08 Sep 2006 10:24:52 +1000, John McMonagle ha scritto:
If you want to create static text that responds to mouse events, try
using the wx.lib.stattext.GenStaticText class.

Add the following import:

import wx.lib.stattext

Then,

self.st = wx.lib.stattext.GenStaticText(self.pnl, -1, 'Static Text
Control', pos=(30,20))
Thankyou very much!

Best regards,

David
Sep 8 '06 #4
Il Fri, 08 Sep 2006 02:32:41 +0200, Amaury Forgeot d'Arc ha scritto:
I quick Google search found the following thread:

http://lists.wxwidgets.org/archive/w.../msg31855.html
or
http://lists.wxwidgets.org/archive/w.../msg31983.html

It suggest that you use another kind of control instead.
Is a disabled TextCtrl acceptable?

Hope this helps,
Yes, it does! Thankyou!

Best regards

David
Sep 8 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: mdk.R | last post by:
Hello all: i'am installed wxPython 2.5 and Python2.3.4..i try execute script with wxPython but it show error: Traceback (most recent call last): File "E:\py\test.py", line 7, in ? import wx...
4
by: KvS | last post by:
Hi all, I'm pretty new to (wx)Python so plz. don't shoot me if I've missed something obvious ;). I have a panel inside a frame, on which a Button and a StaticText is placed: self.panel =...
1
by: PeterG | last post by:
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic...
3
by: John Salerno | last post by:
I'm using the sample code of the file 'simple.py' and trying to make a single window with a panel in it, but I keep getting an error. Here's my code: (I know I might need something else, like a...
3
by: John Salerno | last post by:
I'd be curious to know if this works any differently on other computers/platforms or while other things are happening in the background. I can't tell if it's the Timer object that isn't keep...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
1
by: kath | last post by:
Hello, sorry about the lengthy message. I finding difficult to execute this program. The wx.Notebook i created is coming on the splitted frame(self.p2). How do I that. I am started to learn...
9
by: Tyler | last post by:
Hello All: I am currently working on a project to create an FEM model for school. I was thinking about using wxPython to gather the 12 input variables from the user, then, after pressing the...
3
by: Gandalf | last post by:
I try to reach a specific wx StaticText element's text and to change it by clicking on a button now let's say the this is my element: wx.StaticText(panel, 15, "Hello" ,(30, 70) ,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.