Dev Shed Forums - Python Programming http://forums.devshed.com/ Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language. en Sun, 22 Apr 2018 08:16:13 GMT vBulletin 60 http://forums.devshed.com/images/misc/rss.png Dev Shed Forums - Python Programming http://forums.devshed.com/ <![CDATA[Circles & Arrows]]> http://forums.devshed.com/python-programming/980446-circles-arrows-new-post.html Wed, 11 Apr 2018 13:24:28 GMT This is merely a silly program I felt like posting.
Code:

# python3

import tkinter

# import tkinter.messagebox  cannot set font in a messagebox.  tkinter is ridiculous, I ridicule it.
# tkinter.messagebox.showinfo(master=root, title='Spam', message='Egg Information')

a = 600  # half height
b = 500  # half width
r = 100  # radius

style = (tkinter.PIESLICE, tkinter.CHORD, tkinter.ARC)

def callback(event):
    global r
    r = max(r - 5, 15)
    print('clicked at', event.x, event.y)
    canvas.create_arc(event.x - r, event.y - r, event.x + r, event.y + r,
                      start = 0, extent = 120, outline = 'blue', style = style[r % 3], width = 4)
    canvas.create_line(b, a, event.x, event.y, arrow = tkinter.BOTH)

root = tkinter.Tk()
root.withdraw()  # a little silly
root.title('Circles and arrows')

canvas=tkinter.Canvas(root, height = 2 * a, width = 2 * b)
canvas.pack()
canvas.bind("<Button>", callback)

tkinter.Label(root,  # no reason to save it.
              text = "Click within the `canvas' to choose center of another circle",
              relief = tkinter.RIDGE,
              font = ('times', 36)).pack(
                ipady = 12,
                ipadx = 36)

canvas.create_oval(b - r, a - r, b + r, a + r, fill = 'green', activefill = 'red')

root.deiconify()
root.mainloop()

]]>
Python Programming b49P23TIvg http://forums.devshed.com/python-programming-11/circles-arrows-980446.html
<![CDATA[[Python 3.x + Tkinter] Entry Button not Work, Error Found!]]> http://forums.devshed.com/python-programming/980419-python-3-tkinter-entry-button-error-found-new-post.html Fri, 06 Apr 2018 18:37:45 GMT Hey GUI Programmers and Software Developers... I try to work on my first real app in python 3.x and tkinter... but i get an problem with my entry load file buttons..... This is my script, written in python 3.x in pyScripter.... windows 7 on my laptop: Code: --------- Hey GUI Programmers and Software Developers...

I try to work on my first real app in python 3.x and tkinter... but i get an problem with my entry
load file buttons.....

This is my script, written in python 3.x in pyScripter.... windows 7 on my laptop:

Code:

# Exciner Demo (First Beta Version)
# Created by Jamie van Cadsand
# -------------------------------------------------------------------------------------------------------------------------------------------------------
# Exciner is an "Free and Open Source" Tool for Convert Files
# This is an Beta Version, just not allowed to use in production
# _______________________________________________________________________________________________________________________________________________________
#
# Type Release: Beta
# _______________________________________________________________________________________________________________________________________________________
#
# [Project] Exciner / Exciner.py
# -------------------------------------------------------------------------------------------------------------------------------------------------------



# Import Tkinter
from tkinter import *
from tkinter.messagebox import *

# Define the 'Main Window'
class Run(Frame):

    # Define the 'Main Init'
    def __init__(self, master=None):

        # Call 'Frame' to the 'Main Init'
        Frame.__init__(self, master)

        # Call the window name to master
        self.master = master

        # Call the 'Main Init Window'
        self.init_window()

    # Define the 'Main Init Window'
    def init_window(self):

        # Set 'Main Init Window Title'
        self.master.title("Exciner Demo")
        self.master.config(background = 'gray')

        # PROJECT LOADER  -------------------------------------------------------------------------------------------------------------------------------------------------

        # Call 'Project Loader Variable'
        vname_file = "FileName"

        # Call 'Project Loader Title'
        ploader_title = Label(self.master, text = "PROJECT LOADER:", anchor = W, foreground = 'white', background = 'black')
        ploader_title.pack(fill = X, side = TOP)





        # Call 'Load Project - Image'

        eipload_label = Label(self.master, text = "EIP Project File: ", anchor = W, foreground = 'black', background = 'gray')

        eipl_var = StringVar()
        eipl_var.set(vname_file)
        eipload_entry = Entry(self.master, textvariable = eipl_var, foreground = 'black', background = 'white')
        eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file())

        eipload_label.pack(fill = X, side = TOP)
        eipload_entry.pack(fill = X, side = TOP)
        eipload_button.pack(fill = X, side = TOP)

        eipl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
        eipl_end.pack(fill = X, side = TOP)

        # Call 'Load Project - Audio'
        eapload_label = Label(self.master, text = "EAP Project File: ", anchor = W, foreground = 'black', background = 'gray')

        eapl_var = StringVar()
        eapl_var.set(vname_file)
        eapload_entry = Entry(self.master, textvariable = eapl_var, foreground = 'black', background = 'white')
        eapload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eap_file())

        eapload_label.pack(fill = X, side = TOP)
        eapload_entry.pack(fill = X, side = TOP)
        eapload_button.pack(fill = X, side = TOP)

        eapl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
        eapl_end.pack(fill = BOTH, side = TOP)

        # Call 'Load Project - Video'
        evpload_label = Label(self.master, text = "EVP Project File: ", anchor = W, foreground = 'black', background = 'gray')

        evpl_var = StringVar()
        evpl_var.set(vname_file)
        evpload_entry = Entry(self.master, textvariable = evpl_var, foreground = 'black', background = 'white')
        evpload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_evp_file())

        evpload_label.pack(fill = X, side = TOP)
        evpload_entry.pack(fill = X, side = TOP)
        evpload_button.pack(fill = X, side = TOP)

        evpl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
        evpl_end.pack(fill = X, side = TOP)






        # MENUBAR ----------------------------------------------------------------------------------------------------------------------------------------------------------

        # Call 'Menubar'
        menu = Menu(self.master)
        self.master.config(menu = menu)

        # Call 'File Menu' to the 'Menubar'
        menu_file = Menu(menu, tearoff = False)
        menu_file.add_command(label = "Exit", command = self.client_exit)
        menu.add_cascade(label = "File", menu = menu_file)

        # Call 'Tool Menu' to the 'Menubar'
        menu_tool = Menu(menu, tearoff = False)
        menu_tool.add_command(label = "Image", command = self.open_tool_image)
        menu_tool.add_command(label = "Video", command = self.open_tool_video)
        menu_tool.add_command(label = "Audio", command = self.open_tool_audio)
        menu.add_cascade(label = "Tools", menu = menu_tool)

        # Call 'Help Menu' to the 'Menubar'
        menu_help = Menu(menu, tearoff = False)
        menu_help.add_command(label = "ReadMe", command = self.open_help_read)
        menu_help.add_command(label = "Document", command = self.open_help_doc)
        menu_help.add_command(label = "Channel", command = self.open_help_channel)
        menu.add_cascade(label = "Help", menu = menu_help)

        menu_about = Menu(menu, tearoff = False)
        menu_about.add_command(label = "Report Bug", command = self.open_reporter)
        menu_about.add_command(label = "Do Request", command = self.open_request)
        menu_about.add_command(label = "Copyright", command = self.open_copyright)
        menu_about.add_command(label = "Contact Me", command = self.open_contactbox)
        menu.add_cascade(label = "About", menu = menu_about)



    # _____________________________________________________________________________________________________________________________________________________________________________________


    # COMMANDS PROJECT LOADER -------------------------------------------------------------------------------------------------------------------------------------------------------------

    # Define 'Load EIP' Command [Type: Excine Image Project]
    def load_eip_file(self):

        print("Open EIP File [Excine Image Project]: ", eipload_entry.get())


    # Define 'load EAP' Command [Type: Excine Autio Project]
    def load_eap_file(self):

        print("Open EAP File [Excine Audio Project]: ", eapload_entry.get())

    # Define 'Load EVP' Command [Type: Excine Video Project]
    def load_evp_file(self):

        print("Open EVP FIle [Excine Video Project]: ", evpload_entry.get())



    # COMMANDS MENUBAR --------------------------------------------------------------------------------------------------------------------------------------------------------------------

    # Define the 'tool_image' command
    def open_tool_image(self):

        print("Open Image Editor")


    # Define the 'tool_video' command
    def open_tool_video(self):

        print("Open Video Editor")


    # Define the 'tool_audio' command
    def open_tool_audio(self):

        print("Open Audio Exitor")




    # Define the 'help_read' command
    def open_help_read(self):

        print("Open ReeadMe")

    # Define the 'help_doc' command
    def open_help_doc(self):

        print("Open Doc")

    # Define the 'help_channel' command
    def open_help_channel(self):

        print("Open Channel")




    # Define the 'about_report' command
    def open_reporter(self):

        print("Open Reporter")

    # Define the 'request' command
    def open_request(self):

        print("Open Request")

    # Define the 'copytight' command
    def open_copyright(self):

        print("Open Copyright")

    # Define the 'contactbox' command
    def open_contactbox(self):

        print("Open Contactbox")



    # Define the 'exit' command with build in an askquestion message
    def client_exit(self):

        # Call 'Ask Question Message' to ask if the user want defenitive exit this app
        m_exit = askquestion("Exit Exciner", "Do you want to exit it ?")

        # Exit this app if 'Yes' is pressed
        if m_exit == 'yes':

            # Exit exciner defenitive
            exit()

        # Nothing happens if else
        else:

            # Cancel the exit ommand
            None



# Setup the main window
root = Tk()

# Run the app
App = Run(root)

# Mainloop the main window
root.mainloop()





And this is my error:
Quote:

Traceback (most recent call last):
File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 249, in <module>
App = Run(root)
File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 33, in __init__
self.init_window()
File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 62, in init_window
eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file())
File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 148, in load_eip_file
print("Open EIP File [Excine Image Project]: ", eipload_entry.get())
NameError: name 'eipload_entry' is not defined

So i am an noob in python and i don't know how i can fix this problem...

Oh yeah... my first idea of this app was to make convert files possible, but
this is an old idea... But this not my problem for this topic...

My problem for this topic is the above stand error they i want to ask help to
correct my code to fix this error...

My app is still in the begin fase, just the tools doesn't still (for the tools i work later
on it).... i get still an lot work to do on the demo (or first beta) release of my app....

So... the problem is the error i get in my load project file buttons... but please,
let it for the rest how it is.... the features to load files self must be comming later...

Just only fix this error..., can anyone correct my code please ?...
I use print(...) in my load project commands for the running prompt...

The load project features must be comming later.....

Thanks for help, Jamie ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinter-entry-button-error-found-980419.html
<![CDATA[[Python 3 + pip] Error Found when install Pillow 5.x]]> http://forums.devshed.com/python-programming/980418-python-3-pip-error-found-install-pillow-5-a-new-post.html Fri, 06 Apr 2018 15:12:14 GMT Hello GUI Programmers...

I work on my first app and i want to install Pillow 5.x (last version)...
So i open the command prompt and typ this on 'Windows 7' on my laptop:
Quote:

pip install Pillow
Also i get tryed this command even:
Quote:

pip3 install Pillow
If i try install it via the command prompt, i get an red error on the command prompt...
So install some python packages work fustrated for my.... i get even the same problem
if i install 'Google Trans' on pip, with the command prompt...


Whats wrong with pip ?... i use the last version of 'Python 3.x'.....

Get any python user an idea whats wrong with pip (or Pillow) ?....
So i hope thad eny python user can tell me, how i can fix this problem please ?...

Thanks for help!, Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-pip-error-found-install-pillow-5-a-980418.html
<![CDATA[[Python 3.x + Tkinter] Converting App crasht with exit it, help need!]]> http://forums.devshed.com/python-programming/980412-python-3-tkinter-converting-app-crasht-exit-help-new-post.html Thu, 05 Apr 2018 17:56:37 GMT Hey Software Developers and GUI Programmers...

I am working on my first real app in python 3.x and tkinter... so i am an noob in python
and i try to create an exit button in my file menu in my main menubar...

This is my script (so my app is still in the begin process... just the tools doesn't still)...

Edit:

My script was looks like this...

Code:

# Exciner Demo (First Beta Version)
# Created by Jamie van Cadsand
# -------------------------------------------------------------------------------------------------------------------------------------------------------
# Exciner is an "Free and Open Source" Tool for Convert Files
# This is an Beta Version, just not allowed to use in production
# _______________________________________________________________________________________________________________________________________________________
#
# Type Release: Beta
# _______________________________________________________________________________________________________________________________________________________
#
# [Project] Exciner / Exciner.py
#

from tkinter import *

# Define the 'Main Window'
class Run(Frame):

    def __init__(self, master=None):

        Frame.__init__(self, master)

        self.master = master

        self.init_window()



    def init_window(self):

        self.master.title("Exciner Demo")
        self.pack(fill = BOTH, expand = 1)

        menu = Menu(self.master)
        self.master.config(menu = menu)

        menu_file = Menu(menu, tearoff = False)
        menu_file.add_command(label = "Exit", command = self.client_exit)
        menu.add_cascade(label = "File", menu = menu_file)

        menu_tool = Menu(menu, tearoff = False)
        menu_tool.add_command(label = "Image Type")
        menu_tool.add_command(label = "Image Icon")
        menu_tool.add_command(label = "Image Vector")
        menu_tool.add_separator()
        menu_tool.add_command(label = "Video")
        menu_tool.add_command(label = "Audio")
        menu_tool.add_command(label = "Model")
        menu.add_cascade(label = "Tools", menu = menu_tool)

        menu_help = Menu(menu, tearoff = False)
        menu_help.add_command(label = "ReadMe")
        menu_help.add_command(label = "Document")
        menu_help.add_separator()
        menu_help.add_command(label = "Copyright")
        menu_help.add_command(label = "Report Bug")
        menu_help.add_command(label = "Contact Me")
        menu.add_cascade(label = "Help", menu = menu_help)


    def client_exit(self):

        self.master.quit()




root = Tk()

App = Run(root)

root.mainloop()

So my problem is thad if you press on the "exit" button in my menubar > file > exit...
My App cracht to quit it.... so i get called 'self.master.quit()' in the client_exit(self) command
i get defined...

Can anyone correct my code, just this is fixed on my app ?...
Thanks for help, Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinter-converting-app-crasht-exit-help-980412.html
General questions http://forums.devshed.com/python-programming/980370-questions-new-post.html Sat, 31 Mar 2018 19:22:40 GMT I used to do a lot of coding (C++, Objective C, AS, JS etc) but haven't been into it for a few years. I want to create a program for data analysis from a database. I've decided that Python will be a good fit for that, and I've followed a few tutorials to get a feel for the language, but there's a number of things that are unclear to me. I'm using a Mac.

1. I want this to be an offline, i.e. desktop executable program. How do I do that with Python? Is it possible to create a clickable application that runs straight from the Mac, without having to open up the terminal etc to run Python?
2. I might as well use the best editor I can get, so I was thinking of paying for Pycharm, worth it?
3. I want to store the data in a database. Eventually there may be 100-300k of entries, but there won't be millions. So I was thinking of something like SQLite, but would the database be stored internally in the python program, or would it still be accessed as an external file (which I'd prefer I think)?
4. I want the program itself to have a GUI to allow me to put entries into the database (although I'm also storing them in a excel file right now, and will want to import that into the database at some point). What are the most popular GUI's to use with Python?
5. I know there are a number of data analysis and visualization libraries available for Python. Any suggestions on which would integrate well into what I'm trying to achieve?


Thanks for any help. ]]>
Python Programming Biggerplay http://forums.devshed.com/python-programming-11/questions-980370.html
json parsing http://forums.devshed.com/python-programming/980361-json-parsing-new-post.html Fri, 30 Mar 2018 13:44:48 GMT data = json.load(data_file) File "/usr/lib/python2.7/json/__init__.py", line 291, in load **kw) File "/usr/lib/python2.7/json/__init__.py", line 339, in loads Code:]]> I am trying to parse the json ,but getting the following error

Traceback (most recent call last):
File "a11.py", line 4, in <module>
data = json.load(data_file)
File "/usr/lib/python2.7/json/__init__.py", line 291, in load
**kw)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
Code:

test.py

import json

with open('/home/test/a.json') as data_file:
    data = json.load(data_file)

for a in data['events']:
    a['customParameters'] = a['customParameters'][1]

new_some_json_string = json.dumps(data, indent=2)
 
print(new_some_json_string)


data file :a.json

 "events": [
{
      "time": 1522224314,
      "customParameters": [
{
          "group": "tag",
          "item": "else"
        },

        {
          "group": "url",
          "item": "https://www.xxx.a/3990154.html"
        },
        {
          "group": "title",
          "item": "a90189275"
        }
      ],
      "site": "xx877",
      "type": "test",
      "userId": "xx1"
    }
]

expecting the output
site      type  userId  group  item            group1  item1
xx877  test    xx1      url      https...        title      a90189275

]]>
Python Programming mohanpothula http://forums.devshed.com/python-programming-11/json-parsing-980361.html
<![CDATA[[Python 2.7 + Tkinter] Add Button Array GUI not Works..., Error Found!]]> http://forums.devshed.com/python-programming/980343-python-2-7-tkinter-add-button-array-gui-error-found-new-post.html Thu, 29 Mar 2018 09:27:02 GMT Hey Python Programmers and GUI Developers... I try to create an test GUI, with means you can add an serie buttons if you get an number range typed in an entry.... but if i run my script.... i get an error found... So, this is my script, writting in python 2.7, on an older windows system: Code: --------- Hey Python Programmers and GUI Developers...

I try to create an test GUI, with means you can add an serie buttons if you get an number range
typed in an entry.... but if i run my script.... i get an error found...


So, this is my script, writting in python 2.7, on an older windows system:
Code:

from Tkinter import *

def main():
   
    root = Tk()
    root.geometry("640x480")
    root.title("Button Array")

    can_add = True

    if can_add == True:
       
        a.config(command = AddArray)
       
    else:
       
        a.config(command = None)




    def AddArray():

        try:
            x = 1
            array = range(int(e.get()))

            for x in array:
                b = Button(root, text = int(x), foreground = "white", background = "black", activebackground = "gray")
                b.pack(fill = X, side = TOP)
                x += 1
            can_add = False
            e.delete(0, END)

        except:
            can_add = True
            e.delete(0, END)

       

    def RemoveArray():

        try:
            b.destroy()
            can_add = True

        except:
            can_add = True
       


    e = Entry(root, background = "red")
    a = Button(root, text = "Add", foreground = "white", background = "red", activebackground = "orange")
    d = Button(root, text = "Delete", foreground = "white", background = "red", activebackground = "orange", command = RemoveArray)

    e.pack(fill = X, side = TOP)
    a.pack(fill = X, side = TOP)
    d.pack(fill = X, side = TOP)
       
   
    root.mainloop()



if __name__ == "__main__":
    main()



And this is my error:
Quote:

Traceback (most recent call last):
File "C:/Documents and Settings/Eigenaar/Bureaublad/jamie/Python/Python Tkinter/Tkinter Button Array.py", line 66, in <module>
main()
File "C:/Documents and Settings/Eigenaar/Bureaublad/jamie/Python/Python Tkinter/Tkinter Button Array.py", line 13, in main
a.config(command = AddArray)
UnboundLocalError: local variable 'a' referenced before assignment

The means of my test GUI is thad you can enter an number of buttons thad you want added,
click at the "Add" Button and than must be to cant_added... so than press the "Delete" Button and
than all buttons must be destroyed, just you can add an new number of buttons again... etc.

But i get problems with my GUI, thad i used to play with Tkinter...

Can anyone correct my code, pleace.... just i can experiment with it ?...
Thanks for help, Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-2-7-tkinter-add-button-array-gui-error-found-980343.html
<![CDATA[[Python 3.x Tkinker] Overlap Window Function not works..., Error Found!]]> http://forums.devshed.com/python-programming/980315-python-3-tkinker-overlap-window-function-error-found-new-post.html Sun, 25 Mar 2018 18:09:01 GMT Hey GUI Programmers...

I try to create multiple windows thad make an tool thad must be possible in the "new = Tk" window
and creates an label to the "root = Tk" window, but if you use my tool (just i create an simple
test to make multiple windows with overlapped tools), i get an error...

So i get two scripts... one Run script and one Script, called "Mat", in the "Scripts" folder, imported
"from Scripts.Mat import *" (* = only the script "New")...

This is my Run Script, called "Run.py"...:
Code:

# Import Tkinter to my Script
from tkinter import *
from Scripts.Mat import *

# Make an Main App
def main():

    # Setup App
    root = Tk()
    root.geometry('640x480')
    root.title('Menubar Test')
    root.config(background = 'black')

    # Print (File Menu - Tools)
    def OpenNew():
        New()

    # Make an Basic-Menubar for all Menu's
    menu = Menu(root, foreground = 'white', background = 'blue', relief = SUNKEN)
    root.config(menu = menu)

    # Make an File-Menu (First Command called before my First Seperator for my File Menu)
    file = Menu(menu, foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', tearoff = False)
    file.add_command(label = 'New', command = OpenNew)
    menu.add_cascade(label = 'File', menu = file)

    # App Mainloop
    root.mainloop()

# Check of __name__ __main__ is and start my app if it __main__ is the name
if __name__ == '__main__':
    main()


If you can see.... i get setup my Run app with "root = Tk, ... at last root.mainloop"
and get my second script imported, called "from Scripts.Mat import *" (* is my definded function New())...

And this is my other script, called "Mat"..., with my definded function "New()"...
Code:

from tkinter import *

def New():
    new = Tk()
    new.geometry('640x480')
    new.title('New File')
    new.config(background = 'black')

    def AddLabel():

        l = Label(root, text = 'Label', foreground = 'white', background = 'purple')
        l.pack(fill = X, side = TOP)
       
    b = Button(new, text = 'Add Label', foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', command = AddLabel)
    b.pack(fill = X, side = TOP)
   
    new.mainloop()


The means of my second script (or other script, imported in the run script), is thad
if you press the "File > New" button in my called menu... thad you get my window,
programmed in my second script (called new = Tk())...

But in this window, you get an button to create an label from the "new" window (called
new = Tk()) to the "root" window, called "root = Tk()".....

But if you use my tool (it is just an test app, just i can figure out to build tool-overlaps
in python and tkinter), you get an error...

This is my error, called in my "new = Tk()" window, in my second script...:
Quote:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "C:\Users\Gebruiker\Desktop\Bar\Scripts\Mat.py", line 11, in AddLabel
l = Label(root, text = 'Label', foreground = 'white', background = 'purple')
NameError: name 'root' is not defined
Can anyone help me to fix this problem with my tool overlap in python 3.x and tkinter ?...
Only fix this problem, pleace ?...

Thanks for help, Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinker-overlap-window-function-error-found-980315.html
<![CDATA[[Python 3.x + Tkinter] How do i Change the Basic-Menu Color ?, Help Needed!]]> http://forums.devshed.com/python-programming/980314-python-3-tkinter-change-basic-menu-color-help-new-post.html Sun, 25 Mar 2018 17:23:05 GMT Hey Python Programmers...

I try to change the foreground and background color of my basic-menu, but it don't works...
This is my script, writted in python 3.x, on Windows 10 at my computer:
Code:

# Import Tkinter to my Script
from tkinter import *

# Make an Main App
def main():

    # Setup App
    root = Tk()
    root.geometry('640x480')
    root.title('Menubar Test')
    root.config(background = 'black')

    # Print (File Menu - Tools)
    def PrintNew():
        print('Command : New')

    def PrintOpen():
        print('Command : Open')

    def PrintSave():
        print('Command : Save')

    def PrintSaveAs():
        print('Command : SaveAs')

    def PrintImport():
        print('Command : Import')

    def PrintExport():
        print('Command : Export')


    # Edit (Edit Menu - Tools)
    def EditText():
        print('Edit : Text')

    def EditNodes():
        print('Edit : Nodes')

    def EditData():
        print('Edit : Data')

    def EditPrefs():
        print('Edit : Preference')

    def EditSets():
        print('Edit : Settings')

    # Make an Basic-Menubar for all Menu's
    menu = Menu(root, foreground = 'white', background = 'blue', relief = SUNKEN)
    root.config(menu = menu)

    # Make an File-Menu (First Command called before my First Seperator for my File Menu)
    file = Menu(menu, foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', tearoff = False)
    file.add_command(label = 'New', command = PrintNew)
    file.add_separator()

    # Make an File-Menu (Second, Third and Fourth Command are before my seccond seperator)
    file.add_command(label = 'Open', command = PrintOpen)
    file.add_command(label = 'Save', command = PrintSave)
    file.add_command(label = 'Save As', command = PrintSaveAs)
    file.add_separator()

    # Make an File-Menu (Fifth and Sixth Command are the last commands before my File Cascade to the basic menu (the basic for all Menu's))
    file.add_command(label = 'Import', command = PrintImport)
    file.add_command(label = 'Export', command = PrintExport)
    menu.add_cascade(label = 'File', menu = file)

    # Make an Edit-Menu (First, Second and Thirth Command are before my First Separator for my Edit Menu)
    edit = Menu(menu, foreground = 'white', background = 'blue', activeforeground = 'gray', activebackground = 'cyan', tearoff = False)
    edit.add_command(label = 'Text', command = EditText)
    edit.add_command(label = 'Nodes', command = EditNodes)
    edit.add_command(label = 'Data', command = EditData)
    edit.add_separator()

    # Make an Edit-Menu (Fourth and Fifth Command are before my Edit Cascade to the basic menu (the basic menu for all Menu's))
    edit.add_command(label = 'User Preferences', command = EditPrefs)
    edit.add_command(label = 'Settings', command = EditSets)
    menu.add_cascade(label = 'Edit', menu = edit)

    # App Mainloop
    root.mainloop()

# Check of __name__ __main__ is and start my app if it __main__ is the name
if __name__ == '__main__':
    main()

Just i get called the "foreground = 'white, background = 'blue'" function on the basic menubar,
but if i run my script and my app starts, you will see thad my basic menubar (the menubar
for all menu's (called for "File" and "Edit"), or reather with the variable "menu"), looks just
an "black" foreground and an "white" background, but it must be looks the same like my
partal menus: File and Edit...

Can anyone help me to fix this problem, pleace... ?... and sorry for my font..., all menu's
in apps get an font like as in this app, just like word, blender, paint, etc... they menu's like
looks the same font (text format for the menubars), like as my menubar...

So this is only an menubar with the current font format like in the most menubars in apps...
But further at my problem... pleace...

So can you help me to fix this problem thad i get with my colors for the basic-menu, pleace,
Thanks for help... Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinter-change-basic-menu-color-help-980314.html
<![CDATA[[Python 3.x + Tkinter] Option Menu not Work, tclError Found!]]> http://forums.devshed.com/python-programming/980313-python-3-tkinter-option-menu-tclerror-found-new-post.html Sat, 24 Mar 2018 16:01:51 GMT Hey GUI Programmers... I try to create an option menu thad can change the style, but i get an tclError... This is my script, writting in python 3.x...: Code: --------- from tkinter import * Hey GUI Programmers...

I try to create an option menu thad can change the style, but i get an tclError...

This is my script, writting in python 3.x...:
Code:

from tkinter import *


def main():
    root = Tk()
    root.geometry('640x480')
    root.title('Styles')
    root.config(background = 'white')

    select = 'Defeult'

    def GetStyle(optionselect):
        global select
        select = optionselect

        if select == styles[0]:
            root.config(background = 'white')
            b.config(foreground = 'black', background = 'white')
            o.config(foreground = 'black', background = 'white')

        if select == styles[1]:
            root.config(background = 'gray')
            b.config(foreground = 'black', background = 'red')
            o.config(foreground = 'black', background = 'red')

        if select == styles[2]:
            root.config(background = 'black')
            b.config(foreground = 'white', background = 'purple')
            o.config(foreground = 'white', background = 'purple')
   
    b = Button(root, text = 'TestButton', foreground = 'black', background = 'white')
    b.pack(fill = X, side = TOP)

    styles = ['Defeult', 'Grayscale', 'Blackhole']

    ovar = StringVar()
    ovar.set(styles[0])
    o = OptionMenu(root, var = ovar, *styles, foreground = 'black', background = 'white', command = GetStyle)


    root.mainloop()

if __name__ = '__main__':
    main()

I don't know how i can fix this problem, but for more information to see whats wrong with my
code, run this script and see my error pleace...

Can anyone help me to fix this problem and correct my code, just i can experiment with it ?...
Thanks, Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinter-option-menu-tclerror-found-980313.html
<![CDATA[[Python 3.x + Tkinter] Clock not Work, Help Needed!]]> http://forums.devshed.com/python-programming/980310-python-3-tkinter-clock-help-new-post.html Fri, 23 Mar 2018 19:57:15 GMT Hey Python Programmers...

I try to create an clock like program in python and tkinter... but the time don't update
the seconds in my label... or reather, the seconds give still the same numbers on my
label in tkinter and python 3.x...

This is my script, written in pyScripter, Python 3.x...

Code:

from datetime import datetime
from tkinter import *

root = Tk()
root.geometry('640x480')
root.title('Clock')

now = datetime.now()

l = Label(root, text = int(now.second), foreground = 'white', background = 'black')
l.pack(fill = X, side = TOP)

root.mainloop()

If you don't know about whats wrong... run my script and see whats happend in my
clock.... the seconds (i get only seconds called in my code) get still the same time (or
numbers are only the same numbers as you start my app)....

Can anyone correct my code, just the time are updated in numbers like an digital clock...
My time numbers don't leap further in seconds....

Can anyone help me ?...., thanks for help,
Jamie. ]]>
Python Programming JamieVanCadsand http://forums.devshed.com/python-programming-11/python-3-tkinter-clock-help-980310.html