Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

housie numbers using python

import random
list1=random.sample(range(1,91), 90) 
my_iter=iter(list1) # creating iterator
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("410x500")  # Size of the window 
my_w.title('www.plus2net.com')

font1=('times', 64, 'bold')  # font style of Last call 
font2=('times', 14, 'normal') # font style of grid numbers
font3=('times', 20, 'bold')  # font style of the button

b1=tk.Button(my_w,text='Next',font=font3,command=lambda:my_next())
b1.grid(row=1,column=1,columnspan=5) # show the button to click

str1=tk.StringVar() # Last call to display 
str2=tk.StringVar() # Previous to Last call 
str1.set(0)  # Initial value
str2.set(0)  # Initial value
l1=tk.Label(my_w,textvariable=str1,font=font1) # Show the call
l1.grid(row=1,column=5,columnspan=3,padx=10) 
l2=tk.Label(my_w,textvariable=str2) # show previous to call
l2.grid(row=1,column=9,padx=10)

buttons=[] # to store reference to buttons

def display_no(): # display all buttons at starting
    row=3
    col=2
    for i in range(1,91):
        btn = tk.Button(my_w, text=i,font=font2,
         bg='#ffffff',fg='#C0c0c0')
        btn.grid(row=row, column=col,padx=2)
        if(col==11):  # one row is complete, move next 
            col=2     # staring column 
            row=row+1 # next row 
        else:
            col=col+1 # move to next column ( same row ) 
        buttons.append(btn) # keep the button reference 
global s_no2
s_no2=0

def my_next(): # Click of Next button 
    global s_no2
    #print(s_no2)
    str2.set(str(s_no2)) # set the previous call number
    try:
        s_no=next(my_iter) # Get the call number
        buttons[s_no-1].config(bg="lightgreen",fg='#000000')
        str1.set(str(s_no)) 
        s_no2=s_no # store to use as previous call number
    except StopIteration: # No more number available
        str1.set('0')
        print ("This is a StopIteration error")
    
display_no() # show all the numbers in layout

copyright_symbol = u"u00A9"
l1_end=tk.Label(my_w,text=copyright_symbol) # footer messages
l1_end.grid(row=14,column=1,padx=4)
l2_end=tk.Label(my_w,text='www.plus2net.com') #footer
l2_end.grid(row=14,column=2,columnspan=5,padx=20,pady=10)

my_w.mainloop()  # Keep the window open
« Python Tkinter Projects
Comment

housie numbers using python

import random
list1=random.sample(range(1,91), 90) 
my_iter=iter(list1) # creating iterator
import tkinter as tk
my_w = tk.Tk()
my_w.geometry("410x500")  # Size of the window 
my_w.title('www.plus2net.com')

font1=('times', 64, 'bold')  # font style of Last call 
font2=('times', 14, 'normal') # font style of grid numbers
font3=('times', 20, 'bold')  # font style of the button

b1=tk.Button(my_w,text='Next',font=font3,command=lambda:my_next())
b1.grid(row=1,column=1,columnspan=5) # show the button to click

str1=tk.StringVar() # Last call to display 
str2=tk.StringVar() # Previous to Last call 
str1.set(0)  # Initial value
str2.set(0)  # Initial value
l1=tk.Label(my_w,textvariable=str1,font=font1) # Show the call
l1.grid(row=1,column=5,columnspan=3,padx=10) 
l2=tk.Label(my_w,textvariable=str2) # show previous to call
l2.grid(row=1,column=9,padx=10)

buttons=[] # to store reference to buttons

def display_no(): # display all buttons at starting
    row=3
    col=2
    for i in range(1,91):
        btn = tk.Button(my_w, text=i,font=font2,
         bg='#ffffff',fg='#C0c0c0')
        btn.grid(row=row, column=col,padx=2)
        if(col==11):  # one row is complete, move next 
            col=2     # staring column 
            row=row+1 # next row 
        else:
            col=col+1 # move to next column ( same row ) 
        buttons.append(btn) # keep the button reference 
global s_no2
s_no2=0

def my_next(): # Click of Next button 
    global s_no2
    #print(s_no2)
    str2.set(str(s_no2)) # set the previous call number
    try:
        s_no=next(my_iter) # Get the call number
        buttons[s_no-1].config(bg="lightgreen",fg='#000000')
        str1.set(str(s_no)) 
        s_no2=s_no # store to use as previous call number
    except StopIteration: # No more number available
        str1.set('0')
        print ("This is a StopIteration error")
    
display_no() # show all the numbers in layout

copyright_symbol = u"u00A9"
l1_end=tk.Label(my_w,text=copyright_symbol) # footer messages
l1_end.grid(row=14,column=1,padx=4)
l2_end=tk.Label(my_w,text='www.plus2net.com') #footer
l2_end.grid(row=14,column=2,columnspan=5,padx=20,pady=10)

my_w.mainloop()  # Keep the window open
« Python Tkinter Projects
Comment

PREVIOUS NEXT
Code Example
Python :: regular expressions in python 
Python :: python wrapper function 
Python :: python vars 
Python :: ndarray python 
Python :: How to Loop Through Sets in python 
Python :: django add to cart 
Python :: how to list gym envirolments 
Python :: how to fit the whole text beside checkbox in ipywidgets 
Python :: how to draw threshold line in bar graph python 
Python :: sqlalchemy create engine Oracle 
Python :: pandas.describe per group 
Python :: python list comprehension nested loop 
Python :: query set 
Python :: how to check system has internet using python 
Python :: append two dfs 
Python :: pytorch tensor argmax 
Python :: scikit learn decision tree 
Python :: python print main arguments 
Python :: how to looks like a hacker 
Python :: Returns a DataFrame representing the result of the given query 
Python :: __add__ 
Python :: find daily aggregation in pandas 
Python :: using polymorphism in python 
Python :: round to the nearest 0.5 
Python :: how to add user input for a question python 
Python :: python wifi moudel [WinError 2] The system cannot find the file specified 
Python :: Python program to count Even and Odd numbers using while loop in a List 
Python :: get all permutations of string 
Python :: numpy random entries not repeat 
Python :: # convert string to date 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =