''' tk_button_image_toggle.py using itertools.cycle() to create a Tkinter ToogleUpDownImageButton tested with Python27 by vegaseat 01aug2014 ''' import itertools as it try: # Python27 import Tkinter as tk except ImportError: # Python3+ import tkinter as tk class ToogleUpDownImageButton(tk.Tk): def __init__(self): tk.Tk.__init__(self) # images are of an up and down button # pick GIF images you have in the working directory or give full path self.image_up = tk.PhotoImage(file='btn_up.gif') self.image_down = tk.PhotoImage(file='btn_down.gif') self.images = it.cycle([self.image_down, self.image_up]) self.button = tk.Button(self, image=self.image_up, command=self.toggle) self.button.pack() def toggle(self): """ toggle between up and down button images """ self.button['image'] = next(self.images) def main(): app = ToogleUpDownImageButton() app.mainloop() main()
Isn't it about time forums rewarded their contributors?
Contribute to this discussion and earn rewards points that can be cashed out for dollars.
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...
Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.
This is the result of previous question answered :
code for the listbox - datagridview interaction
At the top of the code ...
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...