Time_label = Label(bottom_frame, text='', font=('Poppins 10 bold')) Result_label = Label(bottom_frame, text='', font=('Poppins 10 bold')) # an empty label for displaying the result To_currency_combo = ttk.Combobox(bottom_frame, width=14, font=('Poppins 10 bold'))Īmount_label = Label(bottom_frame, text='AMOUNT:', font=('Poppins 10 bold'))Īmount_entry = Entry(bottom_frame, width=25, font=('Poppins 15 bold')) # this is the combobox for holding to_currencies # this is the combobox for holding from_currenciesįrom_currency_combo = ttk.Combobox(bottom_frame, width=14, font=('Poppins 10 bold')) To_currency_label = Label(bottom_frame, text='TO:', font=('Poppins 10 bold'), justify=RIGHT) It will look as followsīelow the name_label paste this code: # the top frameīottom_frame = Frame(window, width=300, height=250)įrom_currency_label = Label(bottom_frame, text='FROM:', font=('Poppins 10 bold'), justify=LEFT) Let us now create the bottom frame this frame will contain widgets like labels, comboboxes, entry, and a button. The top frame must be placed inside the main window that we have just created the frame is taking three other attributes, bg, width, and height. We added some colors and created the top frame containing the label. Name_label = Label(top_frame, text='Currency Converter', bg=primary, fg=white, pady=30, padx=24, justify=CENTER, font=('Poppins 20 bold')) Top_frame = Frame(window, bg=primary, width=300, height=80) Paste these lines of code: # colors for the application Just after this line of code: window.resizable(height=FALSE, width=FALSE) The top frame will contain the text "Currency Converter" and it should look like this: Now let us create two frames, the top frame and the button frame. If you run this program, you will get this output: Finally, the mainloop() function will keep the app's window open until the user closes it. We also use the resizable() function with its attributes set to FALSE to make the window non-resizable. To give the window a title, we are using the title() function. We then define the dimensions of the window with the geometry() function. In the above code, we are creating the main window using the Tk() function that comes with Tkinter. # this runs the window infinitely until it is closed Window.resizable(height=FALSE, width=FALSE) # this will make the window not resizable, since height and width is FALSE # this gives the window the width(310), height(320) and the position(center) Open the file and paste this code: # importing everything from tkinter We will start by creating the main window of the application. First of all, create a file named currency_converter.py this is not a convention you can name it whatever you want: In this section, we will start designing the GUI for the application from the ground up. Now that the virtual environment is activated, let's install the requests library: $ pip install requests Designing the Graphical User Interface (GUI) On Linux/macOS: $ source env/bin/activate We will create the virtual environment in this folder and name it env or any name of your choice: $ python -m venv envĪctivate the virtual environment, on Windows: $. We will start by creating the virtual environment and then installing the Python requests library.Ĭreate a folder named currencyconverter and cd into the folder: $ mkdir currencyconverter
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |