Jun-25-2018, 02:51 AM
Is there a solution to this? I made my first ever GUI, and it was a currency converter (with the help of PAGE and google). My uncle wants to see it, so I want to give him an executable. But, I want to impress him so I want everything to be the best it can be.
I don't want the console window to pop up along with the GUI. But when I use --windowed on Pyinstaller, the GUI pops up, but it has NO FUNCTION! Clicking the buttons does nothing.
Is it possible to hide the console whilst still preserving the function of the script fully?
It's a .pyw file, I tried with .py too.
Here's the script if it at all it could provide clues:
Thx.
I don't want the console window to pop up along with the GUI. But when I use --windowed on Pyinstaller, the GUI pops up, but it has NO FUNCTION! Clicking the buttons does nothing.
Is it possible to hide the console whilst still preserving the function of the script fully?
It's a .pyw file, I tried with .py too.
Here's the script if it at all it could provide clues:
#! /usr/bin/env python # -*- coding: utf-8 -*- # # GUI module generated by PAGE version 4.14 # In conjunction with Tcl version 8.6 # Jun 15, 2018 02:37:37 PM from playsound import playsound #import time CurrencyTaken1 = "USD" CurrencyTaken2 = "USD" CurrencyOld1 = "USD" CurrencyOld2 = "USD" FromCurrency = 0 ToCurrency = 0 Amount = "" import sys import pymsgbox import tkinter.messagebox as Msg try: from Tkinter import * except ImportError: from tkinter import * try: import ttk py3 = False except ImportError: import tkinter.ttk as ttk py3 = True import unknown_support def vp_start_gui(): '''Starting point when module is the main routine.''' global val, w, root root = Tk() root.resizable(False, False) top = Converter (root) unknown_support.init(root, top) root.mainloop() w = None def create_Converter(root, *args, **kwargs): '''Starting point when module is imported by another program.''' global w, w_win, rt rt = root w = Toplevel (root) top = Converter (w) unknown_support.init(w, top, *args, **kwargs) return (w, top) def destroy_Converter(): global w w.destroy() w = None CurrencyCountry = {'USD' : 'US Dollar', 'EUR' : 'Euro', 'GBP' : 'British Pound', 'INR' : 'Indian Rupee', 'AUD' : 'Australian Dollar', 'CAD' : 'Canadian Dollar', 'SGD' : 'Singapore Dollar', 'CHF' : 'Swiss Franc', 'MYR' : 'Malaysian Ringgit', 'JPY' : 'Japanese Yen', 'CNY' : 'Chinese Yuan Renminbi', 'NZD' : 'New Zealand Dollar', 'THB' : 'Thai Baht', 'HUF' : 'Hungarian Forint', 'AED' : 'Emirati Dirham', 'HKD' : 'Hong Kong Dollar', 'MXN' : 'Mexican Peso', 'ZAR' : 'South African Rand', 'PHP' : 'Philippine Piso', 'SEK' : 'Swedish Krona', 'IDR' : 'Indonesian Rupiah', 'SAR' : 'Saudi Arabian Riyal', 'BRL' : 'Brazilian Real', 'TRY' : 'Turkish Lira', 'KES' : 'Kenyan Shilling', 'KRW' : 'South Korean Won', 'EGP' : 'Egyptian Pound', 'IQD' : 'Iraqi Dinar', 'NOK' : 'Norwegian Krone', 'KWD' : 'Kuwaiti Dinar', 'RUB' : 'Russian Ruble', 'DKK' : 'Danish Krone', 'PKR' : 'Pakistani Rupee', 'ILS' : 'Israeli Shekel', 'PLN' : 'Polish Zloty', 'QAR' : 'Qatari Riyal', 'XAU' : 'Gold Ounce', 'OMR' : 'Omani Rial', 'COP' : 'Colombian Peso', 'CLP' : 'Chilean Peso', 'TWD' : 'Taiwan New Dollar', 'ARS' : 'Argentine Peso', 'CZK' : 'Czech Koruna', 'VND' : 'Vietnamese Dong', 'MAD' : 'Moroccan Dirham', 'JOD' : 'Jordanian Dinar', 'BHD' : 'Bahraini Dinar', 'XOF' : 'CFA Franc', 'LKR' : 'Sri Lankan Rupee', 'UAH' : 'Ukrainian Hryvnia', 'NGN' : 'Nigerian Naira', 'TND' : 'Tunisian Dinar', 'UGX' : 'Ugandan Shilling', 'RON' : 'Romanian Leu', 'BDT' : 'Bangladeshi Taka', 'PEN' : 'Peruvian Sol', 'GEL' : 'Georgian Lari', 'XAF' : 'Central African CFA Franc BEAC', 'FJD' : 'Fijian Dollar', 'VEF' : 'Venezuelan Bolívar', 'BYN' : 'Belarusian Ruble', 'HRK' : 'Croatian Kuna', 'UZS' : 'Uzbekistani Som', 'BGN' : 'Bulgarian Lev', 'DZD' : 'Algerian Dinar', 'IRR' : 'Iranian Rial', 'DOP' : 'Dominican Peso', 'ISK' : 'Icelandic Krona', 'XAG' : 'Silver Ounce', 'CRC' : 'Costa Rican Colon', 'SYP' : 'Syrian Pound', 'LYD' : 'Libyan Dinar', 'JMD' : 'Jamaican Dollar', 'MUR' : 'Mauritian Rupee', 'GHS' : 'Ghanaian Cedi', 'AOA' : 'Angolan Kwanza', 'UYU' : 'Uruguayan Peso', 'AFN' : 'Afghan Afghani', 'LBP' : 'Lebanese Pound', 'XPF' : 'CFP Franc', 'TTD' : 'Trinidadian Dollar', 'TZS' : 'Tanzanian Shilling', 'ALL' : 'Albanian Lek', 'XCD' : 'East Caribbean Dollar', 'GTQ' : 'Guatemalan Quetzal', 'NPR' : 'Nepalese Rupee', 'BOB' : 'Bolivian Bolíviano', 'ZWD' : 'Zimbabwean Dollar', 'BBD' : 'Barbadian or Bajan Dollar', 'CUC' : 'Cuban Convertible Peso', 'LAK' : 'Lao Kip', 'BND' : 'Bruneian Dollar', 'BWP' : 'Botswana Pula', 'HNL' : 'Honduran Lempira', 'PYG' : 'Paraguayan Guarani', 'ETB' : 'Ethiopian Birr', 'NAD' : 'Namibian Dollar', 'PGK' : 'Papua New Guinean Kina', 'SDG' : 'Sudanese Pound', 'MOP' : 'Macau Pataca', 'NIO' : 'Nicaraguan Cordoba', 'BMD' : 'Bermudian Dollar', 'KZT' : 'Kazakhstani Tenge', 'PAB' : 'Panamanian Balboa', 'BAM' : 'Bosnian Convertible Marka', 'GYD' : 'Guyanese Dollar', 'YER' : 'Yemeni Rial', 'MGA' : 'Malagasy Ariary', 'KYD' : 'Caymanian Dollar', 'MZN' : 'Mozambican Metical', 'RSD' : 'Serbian Dinar', 'SCR' : 'Seychellois Rupee', 'AMD' : 'Armenian Dram', 'SBD' : 'Solomon Islander Dollar', 'AZN' : 'Azerbaijan Manat', 'SLL' : 'Sierra Leonean Leone', 'TOP' : 'Tongan Paanga', 'BZD' : 'Belizean Dollar', 'MWK' : 'Malawian Kwacha', 'GMD' : 'Gambian Dalasi', 'BIF' : 'Burundian Franc', 'SOS' : 'Somali Shilling', 'HTG' : 'Haitian Gourde', 'GNF' : 'Guinean Franc', 'MVR' : 'Maldivian Rufiyaa', 'MNT' : 'Mongolian Tughrik', 'CDF' : 'Congolese Franc', 'STD' : 'Sao Tomean Dobra', 'TJS' : 'Tajikistani Somoni', 'KPW' : 'North Korean Won', 'MMK' : 'Burmese Kyat', 'LSL' : 'Basotho Loti', 'LRD' : 'Liberian Dollar', 'KGS' : 'Kyrgyzstani Som', 'GIP' : 'Gibraltar Pound', 'XPT' : 'Platinum Ounce', 'MDL' : 'Moldovan Leu', 'CUP' : 'Cuban Peso', 'KHR' : 'Cambodian Riel', 'MKD' : 'Macedonian Denar', 'VUV' : 'Ni-Vanuatu Vatu', 'MRO' : 'Mauritanian Ouguiya', 'ANG' : 'Dutch Guilder', 'SZL' : 'Swazi Lilangeni', 'CVE' : 'Cape Verdean Escudo', 'SRD' : 'Surinamese Dollar', 'XPD' : 'Palladium Ounce', 'SVC' : 'Salvadoran Colon', 'BSD' : 'Bahamian Dollar', 'XDR' : 'IMF Special Drawing Rights', 'RWF' : 'Rwandan Franc', 'AWG' : 'Aruban or Dutch Guilder', 'DJF' : 'Djiboutian Franc', 'BTN' : 'Bhutanese Ngultrum', 'KMF' : 'Comorian Franc', 'WST' : 'Samoan Tala', 'SPL' : 'Seborgan Luigino', 'ERN' : 'Eritrean Nakfa', 'FKP' : 'Falkland Island Pound', 'SHP' : 'Saint Helenian Pound', 'JEP' : 'Jersey Pound', 'TMT' : 'Turkmenistani Manat', 'TVD' : 'Tuvaluan Dollar', 'IMP' : 'Isle of Man Pound', 'GGP' : 'Guernsey Pound', 'ZMW' : 'Zambian Kwacha' } CurrencyRate = { 'USD' : 1.0000000000, 'EUR' : 0.8497020274, 'GBP' : 0.7460790068, 'INR' : 67.5410413097, 'AUD' : 1.3155995656, 'CAD' : 1.2925147453, 'SGD' : 1.3353000533, 'CHF' : 0.9852320326, 'MYR' : 3.9900932088, 'JPY' : 109.5526014653, 'CNY' : 6.4031926025, 'NZD' : 1.4220325164, 'THB' : 32.0924026670, 'HUF' : 272.8807324710, 'AED' : 3.6725000000, 'HKD' : 7.8462764575, 'MXN' : 20.3796379598, 'ZAR' : 13.1005133566, 'PHP' : 52.9554231017, 'SEK' : 8.7205380774, 'IDR' : 13933.7702594210, 'SAR' : 3.7500000000, 'BRL' : 3.7036084287, 'TRY' : 4.4744702082, 'KES' : 100.9507258839, 'KRW' : 1074.1679661986, 'EGP' : 17.8523230010, 'IQD' : 1184.8760502828, 'NOK' : 8.0578778328, 'KWD' : 0.3028867393, 'RUB' : 62.3941446821, 'DKK' : 6.3292999706, 'PKR' : 115.8747168742, 'ILS' : 3.5715468629, 'PLN' : 3.6381343233, 'QAR' : 3.6400000000, 'XAU' : 0.0007699843, 'OMR' : 0.3845000000, 'COP' : 2858.5634016656, 'CLP' : 630.0274913381, 'TWD' : 29.8849581129, 'ARS' : 25.2950261874, 'CZK' : 21.8760318331, 'VND' : 22804.4207018530, 'MAD' : 9.4555934604, 'JOD' : 0.7090000000, 'BHD' : 0.3760000000, 'XOF' : 557.3679927872, 'LKR' : 159.0750011515, 'UAH' : 26.2499304193, 'NGN' : 361.0000052338, 'TND' : 2.6048574935, 'UGX' : 3816.7074078348, 'RON' : 3.9584500000, 'BDT' : 83.7821739170, 'PEN' : 3.2816726789, 'GEL' : 2.4505999086, 'XAF' : 557.3679927872, 'FJD' : 2.0739998815, 'VEF' : 9.9875000000, 'BYN' : 1.9996728116, 'HRK' : 6.2775001524, 'UZS' : 7949.4999999998, 'BGN' : 1.6618727162, 'DZD' : 117.4018439274, 'IRR' : 42215.0834237200, 'DOP' : 49.4567053406, 'ISK' : 105.9750022089, 'XAG' : 0.0595921127, 'CRC' : 567.7499999998, 'SYP' : 515.1789590993, 'LYD' : 1.3390928024, 'JMD' : 127.1774810527, 'MUR' : 34.3234103492, 'GHS' : 4.7516624995, 'AOA' : 237.9234931252, 'UYU' : 31.3508723868, 'AFN' : 71.4270327954, 'LBP' : 1507.5000000000, 'XPF' : 101.3964233171, 'TTD' : 6.7802079448, 'TZS' : 2275.5039241055, 'ALL' : 108.0749969480, 'XCD' : 2.7024707691, 'GTQ' : 7.3341602643, 'NPR' : 108.5722239053, 'BOB' : 6.8819403348, 'ZWD' : 361.9000000000, 'BBD' : 2.0000000000, 'CUC' : 1.0000000000, 'LAK' : 8354.5556109593, 'BND' : 1.3353000533, 'BWP' : 10.1317005202, 'HNL' : 23.9225479801, 'PYG' : 5651.0259444846, 'ETB' : 27.5499992369, 'NAD' : 13.1005133566, 'PGK' : 3.1694999299, 'SDG' : 18.0650826692, 'MOP' : 8.0816647512, 'NIO' : 31.5099983213, 'BMD' : 1.0000000000, 'KZT' : 334.5288202358, 'PAB' : 1.0000000000, 'BAM' : 1.6618727162, 'GYD' : 207.1384026579, 'YER' : 249.8284561801, 'MGA' : 3290.4995032829, 'KYD' : 0.8204821039, 'MZN' : 59.3667276528, 'RSD' : 100.2259971423, 'SCR' : 13.9881412522, 'AMD' : 483.2200012209, 'SBD' : 7.9050998922, 'AZN' : 1.7000000479, 'SLL' : 7900.0495371841, 'TOP' : 2.2864609617, 'BZD' : 2.0149695273, 'MWK' : 723.4439406152, 'GMD' : 47.2200012201, 'BIF' : 1760.9635283649, 'SOS' : 573.0000398719, 'HTG' : 66.4788280436, 'GNF' : 9046.7459673068, 'MVR' : 15.6664543616, 'MNT' : 2408.4921907719, 'CDF' : 1570.4816066171, 'STD' : 20847.8232150300, 'TJS' : 9.0562000273, 'KPW' : 899.9904707532, 'MMK' : 1344.8725535880, 'LSL' : 13.1005133566, 'LRD' : 138.8778135227, 'KGS' : 68.3444976809, 'GIP' : 0.7460790068, 'XPT' : 0.0011021248, 'MDL' : 16.7465967952, 'CUP' : 26.5000000000, 'KHR' : 4059.6649390394, 'MKD' : 52.1772518744, 'VUV' : 107.3992312384, 'MRO' : 356.4688463413, 'ANG' : 1.7921709250, 'SZL' : 13.1005133566, 'CVE' : 93.6966425614, 'SRD' : 7.4247194371, 'XPD' : 0.0009860908, 'SVC' : 8.7500000000, 'BSD' : 1.0000000000, 'XDR' : 0.7045925215, 'RWF' : 857.9053222830, 'AWG' : 1.7900000000, 'DJF' : 177.9676958809, 'BTN' : 67.5410413097, 'KMF' : 418.0259945904, 'WST' : 2.5647129853, 'SPL' : 0.1666666660, 'ERN' : 15.0000000000, 'FKP' : 0.7460790068, 'SHP' : 0.7460790068, 'JEP' : 0.7460790068, 'TMT' : 3.4999999998, 'TVD' : 1.3155995656, 'IMP' : 0.7460790068, 'GGP' : 0.7460790068, 'ZMW' : 10.2310718223 } class Converter: def SubmitCurrency1(self, event): playsound('Click.mp3') # First submit button global CurrencyTaken1 CurrencyTaken1 = Entry.get(self.Entry1) self.Entry1.delete(0, 'end') if CurrencyTaken1 not in CurrencyCountry: pymsgbox.native.alert("Please type a valid currency code to convert." ,"Converter") CurrencyTaken1 = "USD" #CurrencyTaken1 = CurrencyOld1 else: #CurrencyOld1 = CurrencyTaken1 self.Label1.config(text= CurrencyTaken1) def SubmitCurrency2(self, event): playsound('Click.mp3') # Second submit button global CurrencyTaken2 CurrencyTaken2 = Entry.get(self.Entry1_1) self.Entry1_1.delete(0, 'end') if CurrencyTaken2 not in CurrencyCountry: pymsgbox.native.alert("Please type a valid currency code to convert." ,"Converter") CurrencyTaken2 = "USD" #CurrencyTaken2 = CurrencyOld2 else: #CurrencyOld2 = CurrencyTaken2 self.Label1_3.config(text= CurrencyTaken2) def ConvertCurrency(self, event): playsound('Click.mp3') Amount = Entry.get(self.Entry2) self.Entry2.delete(0, 'end') if not Amount: pymsgbox.native.alert("Please select an amount" ,"Converter") else: Rate = round(((float(Amount))/float(CurrencyRate[CurrencyTaken1]))*float(CurrencyRate[CurrencyTaken2]), 2) Rates = str(Rate) text = "The amount of '" + str(CurrencyCountry[CurrencyTaken2]) + "' you will get out of " + str(round(float(Amount), 2)) + " '" + str(CurrencyCountry[CurrencyTaken1]) + "' is " + "\n\t" + Rates pymsgbox.native.alert(text ,"Converter") def callback(self, Entry1Variable): self.Entry1Variable.set(self.Entry1Variable.get().upper()) if not self.Entry1Variable.get().isalpha(): corrected = ''.join(filter(str.isalpha, self.Entry1Variable.get())) self.Entry1Variable.set(corrected) self.Entry1Variable.set(self.Entry1Variable.get()[:3]) def callback2(self, Entry2Variable): if not self.Entry2Variable.get().isalpha(): corrected = ''.join(filter(str.isalpha, self.Entry2Variable.get())) self.Entry2Variable.set(corrected) self.Entry2Variable.set(self.Entry2Variable.get().upper()) self.Entry2Variable.set(self.Entry2Variable.get()[:3]) def callback3(self, AmountVariable): if not self.AmountVariable.get().isnumeric(): corrected = ''.join(filter(str.isnumeric, self.AmountVariable.get())) self.AmountVariable.set(corrected) self.AmountVariable.set(self.AmountVariable.get()[:16]) def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#d9d9d9' # X11 color: 'gray85' top.geometry("228x101+504+157") top.title("Converter") top.configure(background="#d9d9d9") self.Entry1Variable = StringVar() self.Entry1Variable.trace("w", lambda name, index, mode, Entry1Variable=self.Entry1Variable: self.callback(self.Entry1Variable)) self.Entry2Variable = StringVar() self.Entry2Variable.trace("w", lambda name, index, mode, Entry2Variable=self.Entry2Variable: self.callback2(self.Entry2Variable)) self.AmountVariable = StringVar() self.AmountVariable.trace("w", lambda name, index, mode, AmountVariable=self.AmountVariable: self.callback3(self.AmountVariable)) self.Entry1 = Entry(top, textvariable = self.Entry1Variable) self.Entry1.place(relx=0.04, rely=0.1,height=20, relwidth=0.19) self.Entry1.configure(background="white") self.Entry1.configure(disabledforeground="#a3a3a3") self.Entry1.configure(font="TkFixedFont") self.Entry1.configure(foreground="#000000") self.Entry1.configure(insertbackground="black") self.Entry1.configure(width=44) self.Entry1.bind("<Return>", self.SubmitCurrency1) self.Entry1_1 = Entry(top, textvariable = self.Entry2Variable) self.Entry1_1.place(relx=0.04, rely=0.4,height=20, relwidth=0.19) self.Entry1_1.configure(background="white") self.Entry1_1.configure(disabledforeground="#a3a3a3") self.Entry1_1.configure(font="TkFixedFont") self.Entry1_1.configure(foreground="#000000") self.Entry1_1.configure(highlightbackground="#d9d9d9") self.Entry1_1.configure(highlightcolor="black") self.Entry1_1.configure(insertbackground="black") self.Entry1_1.configure(selectbackground="#c4c4c4") self.Entry1_1.configure(selectforeground="black") self.Entry1_1.bind("<Return>", self.SubmitCurrency2) self.Button1 = Button(top) self.Button1.place(relx=0.26, rely=0.09, height=24, width=49) self.Button1.configure(activebackground="#d9d9d9") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''Submit''') self.Button1.bind("<Button-1>", self.SubmitCurrency1) self.Button1_2 = Button(top) self.Button1_2.place(relx=0.26, rely=0.38, height=24, width=49) self.Button1_2.configure(activebackground="#d9d9d9") self.Button1_2.configure(activeforeground="#000000") self.Button1_2.configure(background="#d9d9d9") self.Button1_2.configure(disabledforeground="#a3a3a3") self.Button1_2.configure(foreground="#000000") self.Button1_2.configure(highlightbackground="#d9d9d9") self.Button1_2.configure(highlightcolor="black") self.Button1_2.configure(pady="0") self.Button1_2.configure(text='''Submit''') self.Button1_2.bind("<Button-1>", self.SubmitCurrency2) self.Label1 = Label(top) self.Label1.place(relx=0.53, rely=0.1, height=21, width=28) self.Label1.configure(background="#d9d9d9") self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(foreground="#000000") self.Label1.configure(text='''USD''') self.Label1_3 = Label(top) self.Label1_3.place(relx=0.53, rely=0.4, height=21, width=28) self.Label1_3.configure(activebackground="#f9f9f9") self.Label1_3.configure(activeforeground="black") self.Label1_3.configure(background="#d9d9d9") self.Label1_3.configure(disabledforeground="#a3a3a3") self.Label1_3.configure(foreground="#000000") self.Label1_3.configure(highlightbackground="#d9d9d9") self.Label1_3.configure(highlightcolor="black") self.Label1_3.configure(text='''USD''') self.Button2 = Button(top) self.Button2.place(relx=0.7, rely=0.08, height=54, width=57) self.Button2.configure(activebackground="#d9d9d9") self.Button2.configure(activeforeground="#000000") self.Button2.configure(background="#d9d9d9") self.Button2.configure(disabledforeground="#a3a3a3") self.Button2.configure(foreground="#000000") self.Button2.configure(highlightbackground="#d9d9d9") self.Button2.configure(highlightcolor="black") self.Button2.configure(pady="0") self.Button2.configure(text='''Convert''') self.Button2.configure(width=57) self.Button2.bind("<Button-1>", self.ConvertCurrency) self.Label2 = Label(top) self.Label2.place(relx=0.04, rely=0.69, height=26, width=50) self.Label2.configure(background="#d9d9d9") self.Label2.configure(disabledforeground="#a3a3a3") self.Label2.configure(foreground="#000000") self.Label2.configure(text='''Amount''') self.Label2.configure(width=50) self.Entry2 = Entry(top, textvariable = self.AmountVariable) self.Entry2.place(relx=0.31, rely=0.69,height=20, relwidth=0.63) self.Entry2.configure(background="white") self.Entry2.configure(disabledforeground="#a3a3a3") self.Entry2.configure(font="TkFixedFont") self.Entry2.configure(foreground="#000000") self.Entry2.configure(insertbackground="black") self.Entry2.configure(width=144) self.Entry2.bind("<Return>", self.ConvertCurrency) if __name__ == '__main__': vp_start_gui()If PyInstaller does not support this, can you recommend me a compiler that does?
Thx.