473,774 Members | 2,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with current value of wx.SpinCtrl and EVT_SPIN

Hello,

I am new to Python/wxPython and am experiencing first problems. I have
a dialog which includes a SpinCtrl and a Slider. I want the Slider to
affect the SpinCtrl and vice versa
(http://wiki.wxpython.org/index.cgi/C...geDemos#Part1).

The code I wrote does, however, not work correctly. The event EVT_SPIN
is never handled (even though I wrote a handler), and in the handler of
EVT_SCROLL_CHAN GED I do not obtain the modified value, but the value
before the control has changed.

Any feedback would be greatly appreciated.
To clarify my problem, here's the code (Python2.4, wxPython 2.6) :

import wx

class AppFrame(wx.Fra me):
def OnSpinGeneral(s elf, event):
b = wx.MessageBox(" never reached")

def OnSpin(self, event):
# I tried to use Skip so that the changing of the value would
take place before
# I invoke GetValue(), however this has no effect
event.Skip()

print self.spin.GetVa lue()
self.slider.Set Value(self.spin .GetValue())

def OnScrollChanged (self, event):
self.spin.SetVa lue(self.slider .GetValue())

def __init__(self):
wx.Frame.__init __( self,
None, -1, "",
#size=FRAME_SIZ E,
style=wx.DEFAUL T_FRAME_STYLE )
self.sizer = wx.BoxSizer( wx.VERTICAL )

self.spin = wx.SpinCtrl(sel f, min = 0, max = 50)
self.slider = wx.Slider(self, 1, 6, 0, 50)

self.sizer.Add( self.spin)
self.sizer.Add( self.slider)

self.Bind(wx.EV T_SCROLL_CHANGE D, self.OnScrollCh anged,
self.slider)
self.Bind(wx.EV T_SPIN_UP, self.OnSpin, self.spin)
self.Bind(wx.EV T_SPIN_DOWN, self.OnSpin, self.spin)
self.Bind(wx.EV T_SPIN, self.OnSpinGene ral, self.spin)

self.SetSizer(s elf.sizer)
self.SetAutoLay out(1)
self.Show(1)

app = wx.PySimpleApp( )
frame = AppFrame()
app.MainLoop()

Apr 9 '06 #1
3 3724
blackno666 wrote:
I am new to Python/wxPython and am experiencing first problems. I have
a dialog which includes a SpinCtrl and a Slider. I want the Slider to
affect the SpinCtrl and vice versa
(http://wiki.wxpython.org/index.cgi/C...geDemos#Part1).

The code I wrote does, however, not work correctly. The event EVT_SPIN
is never handled (even though I wrote a handler), and in the handler of
EVT_SCROLL_CHAN GED I do not obtain the modified value, but the value
before the control has changed.


Does it *appear* to work? That is, if you run it, does the slider move
if you click on one of the spinner buttons, and does the spinner value
change when you move the slider (and release the button)? Because
that's what happens for me, so I'm not sure what it is that you expected
it to do... (wxPython 2.6.1.0 on WinXP SP2)

-Peter

Apr 9 '06 #2
Yes, it "works". However buggy.

When the slider is set to 0 and the up button is pressed in the
SpinCtrl, the value in the SpinCtrl will be 1, but the slider will not
move. There's also a discrepancy between the value displayed in the
SpinCtrl and the value output by

print self.spin.GetVa lue().

When playing with this code I also noticed that I was not able change
the behaviour of the up and down buttons. I expected that if I modify
OnSpin in the following way:

def OnSpin(self, event):
pass

That pressing the spin buttons would have no effect. However, the value
is still increased or decreased....

Apr 9 '06 #3
Just found a solution to the problem:

when using wx.EVT_SPINCTRL instead of wx.EVT_SPIN_UP, wx.EVT_SPIN_DOW N
or wx.EVT_SPIN the program behaves correctly.

wxWidget documentation for wxSpinCtrl states that "You may also use the
wxSpinButton event macros, however the corresponding events will not be
generated under all platforms"; I ran the program on WinXP SP2.
However, the events seem to be handled (at least EVT_SPIN_UP,
wx.EVT_SPIN_DOW N). So I do not understand why handling these events
leads to a buggy behaviour.

Apr 9 '06 #4

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

Similar topics

5
1922
by: Buchleitner Martin | last post by:
Hi! I got another problem parsing my XML document: <document> <paragraph> <style val=listing/> <text>listing #1 text</text> </paragraph> <paragraph>
4
4629
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input type="checkbox" name="chk_Complete" value="<%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked"%>> The code to captures the checkbox value in the asp page that builds the sql string is follows
11
2174
by: brian.newman | last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the form, but my code doesn't seem to be working and I need some help debugging it. I'm not getting an error which has made it difficult to debug the code, but I am getting the alert ("break 4 in getStyleObject"); which makes me think this is a browser compatability issue (I'm running IE 6.0). Anyway, the code follows function getStyleObject (objectId) { alert ("begin...
5
8800
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) - DAYS(PROBLEMS.CLOSE_DATE)) = 365 AND PROBLEMS.CLOSE_DATE IS NOT NULL But this doesn't: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
6
2881
by: Jamal | last post by:
I am working on binary files of struct ACTIONS I have a recursive qsort/mergesort hybrid that 1) i'm not a 100% sure works correctly 2) would like to convert to iteration Any comments or suggestion for improvements or conversion to iteration would be much appreciated
14
1854
by: Henk | last post by:
Hi Guys, (see actual code below) I wrote a little program that is supposed to read a file (input.txt) into memory (using a stack) and then reverse the file and display it to output. It works, but I still get some errors when i try to compile it: stack.c: In function 'reverseFile'
10
2416
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ComboBox.SelectedValue = db_value; If the db_value was not included in the ComboBox value list the ComboBox.SelectedIndex used to return -1, Now the very same code is
17
2495
by: Lloyd Sheen | last post by:
This IDE is driving me nuts. I needed another button so I copied an existing one, changed the Text and the id and position by drag and drop. Well then I run and get the following: Control 'Button19' of type 'Button' must be placed inside a form tag with runat=server Can the IDE not do what it is supposed to do. It seems that it is a fight to make it do anything or did I do something wrong? It would seem silly to have to create a...
1
5285
by: PowerLifter1450 | last post by:
I've been having a very rough time installinig mySQL on Linux. I have been following the instructions form here: http://www.hostlibrary.com/installing_apache_mysql_php_on_linux Everytime I get to #./configure it goes through all of the preparing tables and starting mysqlServer and daemon, but than immediaetly says "mysql ended" -- I try to do #make right after anyway, but I get the error "No targets specified and no makefile found" -- Any...
0
10267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.