bruce.hagen 0 Newbie Poster

I have a Python file with 50+ frames.
Each frame has 5 radio button and 1 textbox.
Each radio button has a pre-determine numeric value that will print to textbox.

What I would like to do is replace the radio buttons with a combobox.
the combobox is set up with a base numeric value with a math equation.

The principle works but i can only get it to print to shell.

I have tried numerous different code from posts for the past month.

I thought the community may be able to help me.

I have attached a snippet of my code.

Thanks in advance.

from tkinter import *
from tkinter import Tk
import tkinter as tk
from tkinter import ttk
from tkinter.ttk import Combobox
root=tk.Tk()

root.title("Dental Milling Machines")
root.geometry("250x200")


def onclick1():#3M
textbox1.delete('1.0', 'end')
textbox1.insert('end', '2.83')
def onclick2():#3M
textbox1.delete('1.0', 'end')
textbox1.insert('end', '5.66')


def to_float( string ):
try:
    return float( string )
except ValueError:
    return 0.0

def Cnum():
print(combobox2.current()*2.83)


cb_var1 = tk.IntVar()

frame1 = Frame(root, height = 150, width= 150, relief= RAISED, bd=8, bg="blue")

frame1.grid(row=0, column=0, pady=2,sticky="NW")
label = Label(frame1, text="Frame 1", fg="red")
label.grid(row=0, columnspan=3, pady= 1, sticky= "W")

button1=Radiobutton(frame1, text="Submit", command=Cnum)
button1.grid(row=1, column=1, pady= 1, padx= 5, sticky= "W")



textbox1=Text(frame1, borderwidth=1, wrap="none", width=5, height=1)
textbox1.grid(row=0, column=1,padx=10, sticky="W")


combobox2=Combobox(frame1, width=7)
combobox2.grid(row=1, column=0)
combobox2['values'] = ( '', ' 1', ' 2', ' 3', ' 4', ' 5')

button1=Radiobutton(frame1, text="1 Unit ", variable=cb_var1, command=onclick1)
button1.grid(row=2, column=0, pady= 1, padx= 5, sticky= "W")
button2=Radiobutton(frame1, text="2 Unit ", variable=cb_var1, command=onclick2)
button2.grid(row=4, column=0, pady= 1, padx= 5, sticky= "W")

root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.