473,503 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unsupported operand type(s) for +: 'instance' and 'int'

11 New Member
Hi:
I tried to make two buttons that when I click it, the text in the label will increase or decrease. But python told me that "unsupported operand type(s) for +: 'instance' and 'int'" on "labeltext1.set(labeltext1 + 1)" and "labeltext1.set(labeltext1 - 1)". Could you help me solve it? Thanks very much!!

Expand|Select|Wrap|Line Numbers
  1. def Increase(labeltext1):
  2.     for a in range (0, 100): 
  3.         labeltext1.set(labeltext1 + 1)
  4.  
  5. def Decrease(labeltext1):
  6.     for a in range (0, 100):
  7.         labeltext1.set(labeltext1 - 1)
  8.  
  9. labeltext1 = IntVar()
  10. labeltext1.set(0)
  11.  
  12. NumberLabel = Label(root, textvariable = labeltext1)
  13. Button2 = Button(root, text = "Increase")
  14. Button3 = Button(root, text = "Decrease")
  15.  
  16. NumberLabel.grid(row = 1, column = 0)
  17. Button2.grid(row = 5, column = 0)
  18. Button3.grid(row = 6, column = 0)
  19.  
  20. Button2.bind("<Button-1>", Increase(labeltext1))
  21. Button3.bind("<Button-1>", Decrease(labeltext1))
  22.  
Feb 29 '12 #1
1 7510
bvdet
2,851 Recognized Expert Moderator Specialist
To determine the current value of the label text, use the get() method.
Expand|Select|Wrap|Line Numbers
  1. def Increase(labeltext1):
  2.     for a in range (0, 100): 
  3.         labeltext1.set(labeltext1.get() + 1)
Feb 29 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
9667
by: Rakesh | last post by:
In my Python code fragment, I want to write a code fragment such that the minimum element of a tuple is subtracted from all the elements of a given tuple. When I execute the following python...
3
4714
by: Steph | last post by:
Hi, On my first oracle instance, I have a global type 'productarray' (CREATE OR REPLACE TYPE productarray AS TABLE OF VARCHAR(30)), I have a package procedure having myArray OUT productarray as...
11
1660
by: Robert Sturzenegger | last post by:
We had a strange problem in a large project with the use of a string class in a static instance of a struct. I managed to reproduce the exactly same problem in a very short program (see below)....
2
16970
by: coop | last post by:
I have a stored procedure that works fine on SQL Server 2000 or 2005, but when run on an machine running MSDE, I get the Operand type clash, int is incompatible with text data type error. The data...
3
11157
by: Jeffrey Grantz | last post by:
I took the code below from an example of FolderBrowserDialog but I keep getting the subject diagnostic on DialogResult.OK and I can't figure out what I am doing wrong. Any Help? ADVthanksANCE
3
11817
by: tanusreesen | last post by:
Hi All, I am completely new to python programming language.I was trying to write a program on class.But I am getting this error.Can someone please help me to solve the error I am facing.I...
5
3155
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a...
2
1343
by: time_error | last post by:
Hi, Environment: VS2005 standard, programming app/service for WinCE 5.0 I'm trying to use the Win32 DeviceIoControl(...) from C# with P/ Invoke. In my managed C# code the inbuffer of...
8
9488
by: Gilbert Fine | last post by:
This is a very strange exception raised from somewhere in our program. I have no idea how this happen. And don't know how to reproduce. It just occurs from time to time. Can anyone give me some...
5
1912
by: Chad | last post by:
Keith made the following comment " You can convert an int*, or an int**, or an int***, or ... to void* without loss of information -- except that you lose the type information, which you have to...
0
7271
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,...
0
7319
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...
1
6979
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...
0
7449
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...
0
5570
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3160
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...
0
1498
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 ...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
373
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...

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.