Re: [PyInstaller] Re: Pyinstaller: calling another Tkinter restarts the app and doesn't bring up other Toplevel() window.

2020-02-24 Thread JAY JAY
Chris, I really appreciated your very thoughtful and encouraging message. 
This will help me learn python and move forward in a more idiomatic way. 
You rock!! I will spend some time on what you recommend. Looking forward to 
checking out your work too.

Jay

On Monday, 17 February 2020 16:16:59 UTC-6, Chris Barker wrote:
>
> I think you need to rethink a bit what you are doing here:
>
> You are calling a python program from within a python program? Why? Do you 
> need two programs running?
>
> If you do have a good reason, then you need to rethink how you are using 
> PyInstaller (and maybe it's not the right tool).
>
> PyInstaller is designed to make ONE single application out of a pile of 
> Python code. It sounds like you need two (or more?) applications. In which 
> case, I think there are ways to make multiple top level programs that share 
> the same libs, etc. Do a little googling, I can't find it at the moment, 
> but it is possible, if not well tested.
>
> -CHB
>
>
>
>
>
>
> On Mon, Feb 17, 2020 at 12:29 AM JAY JAY  > wrote:
>
>> Yeah soo.. I figured out my problem. BONKERS.
>>
>> Turns out I was using this:
>>
>> subprocess.call([sys.executable,"file"])
>>
>> AAAND.. if you run the python script without pyinstaller, sys.executable = 
>> the python interpreter. In a bundled pyinstaller app, that's NOT WHAT IT 
>> IS!!! It's actually the executable file itself. So, I was inadvertently 
>> running the app over and over. I tell you.. that is just nuts. Seriously 
>> programmers?
>>
>> So, I had to figure out another way to execute my py file inside my py 
>> script. Easy right? Ok, but I needed an argument.. so exec(open(read()) 
>> wouldn't work.. or would it? Apparently this does:
>>
>> sys.argv = ["file.py"), vArguments]
>> exec(open(os.path.join(wd,"tests","errorMessage.py")).read(), globals())
>>
>> Please note that I also included "globals()" there, because apparently exec 
>> won't include any imports unless you do that. WTF? I'm... ambivalent about 
>> Python at the moment. What are all these gotchas??
>>
>>
>> On Sunday, 16 February 2020 16:23:18 UTC-6, JAY JAY wrote:
>>>
>>> I have an app like this
>>>
>>> Main.py (includes root and Tk.Toplevel()) -- PythonDataProcessing.py -- 
>>> tkinterErrorMessage.py (includes another Tk.Toplevel()). 
>>>
>>> When I run this on my computer via python main.py, the initial toplevel 
>>> window opens, and any subsequent error message pulls up toplevel windows as 
>>> expected. When I put it all through Pyinstaller and run the app, instead of 
>>> a tkinter toplevel error message, I get initial main.py toplevel window, 
>>> almost like the program is running itself again. WTF?
>>>
>>> I suspect this has to do with hooks in some way? Has anyone run into 
>>> something like this? Wtf is going on? Like they say.. NOTHING IS EASY! 
>>> Thanks for your help!
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "PyInstaller" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to pyins...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pyinstaller/4aa122fb-a375-4f52-9a6e-a6507dbe695a%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR(206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115   (206) 526-6317   main reception
>
> chris...@noaa.gov 
>

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyinstaller+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/3f4d9acf-9b22-45a2-956b-d6d89e5a79a3%40googlegroups.com.


Re: [PyInstaller] Re: Pyinstaller: calling another Tkinter restarts the app and doesn't bring up other Toplevel() window.

2020-02-18 Thread 'Chris Barker' via PyInstaller
I encourage you to do a little more research into how python works -- in
particular modules and packages - I think you are missing some key points.
A couple comments:

On Tue, Feb 18, 2020 at 12:26 AM JAY JAY  wrote:

> thank you for your message!! the main reason is not having the program be
> an unweildy mess. The user interacts with variables that are used on
> completely different pages, and it's just easier to compile them into
> different scripts rather than one huge file.
>

you absolutely want to structure a larger-than-trivial program in multiple
files -- a python file is a "module", and a "package is a collection of
modules, usually in one dir (with a __init__.py file in it). If you have a
less than trivial application, the functionality should be in multiple
modules, which are imported into the files that need them. There should be
one "top level" script, which is often as simple as something like:

import my_app
my_app.main()


My main problem was that this is the general assumption about python app
> architecture? TK also is built around the idea that there should only be
> one window.
>

no, it's not -- but it is build around teh assumption of one application
running at a time -- you can create any number of windows.


> however I was trying to use the app to spit out tkinter error messages
> whenever there was a user error.
>

you can make error dialogs


> My main problem was not really with pyinstaller but with not using
> Toplevel() as opposed to new instances of tkinter. One of those gotchas.
>

Exactly -- you want ONE Tkinter application...

In a similar way pyinstaller I guess assumes that you'll have one file?
>

not at all -- it assumes that you have one start up script, and then it
will look for anything imported there, and automatically include all of
them.


> Maybe I'm just a newb but I love modularity.
>

good instinct -- yes, you want modularity -- that's why they are called
modules :-)

So, after I figured out I had to add all of these individual files or
> directories via the spec file,
>

you really shouldn't' have to hand manipulate the spec file for anything
"normal"


> I can definitely compile it all under one bundle, which will go different
> places depending on which scripts are activated. Took me a bit but now it's
> more of a package app rather than a single use tool. I like your idea on
> sharing libraries between apps though, I will investigate!!
>

look up how to make a python package -- note that a lot of the docs get
into how to make it available to others via PyPi, which you probably don't
want to do -- but the structure is the same, even if you keep it to
yourself.

This may help you get started:

http://pythonchb.github.io/PythonTopics/where_to_put_your_code.html

In short: you probably want to create a package of all the code you need
for your app. part of that will be a script to start it up.

Then point PyInstaller at that start up script, and presto -- a stand alone
application.

HTH,
-CHB






>
> thank you again for being kind and sharing ur thoughts!
>
> On Mon, Feb 17, 2020, 4:16 PM 'Chris Barker' via PyInstaller <
> pyinstaller@googlegroups.com> wrote:
>
>> I think you need to rethink a bit what you are doing here:
>>
>> You are calling a python program from within a python program? Why? Do
>> you need two programs running?
>>
>> If you do have a good reason, then you need to rethink how you are using
>> PyInstaller (and maybe it's not the right tool).
>>
>> PyInstaller is designed to make ONE single application out of a pile of
>> Python code. It sounds like you need two (or more?) applications. In which
>> case, I think there are ways to make multiple top level programs that share
>> the same libs, etc. Do a little googling, I can't find it at the moment,
>> but it is possible, if not well tested.
>>
>> -CHB
>>
>>
>>
>>
>>
>>
>> On Mon, Feb 17, 2020 at 12:29 AM JAY JAY 
>> wrote:
>>
>>> Yeah soo.. I figured out my problem. BONKERS.
>>>
>>> Turns out I was using this:
>>>
>>> subprocess.call([sys.executable,"file"])
>>>
>>> AAAND.. if you run the python script without pyinstaller, sys.executable = 
>>> the python interpreter. In a bundled pyinstaller app, that's NOT WHAT IT 
>>> IS!!! It's actually the executable file itself. So, I was inadvertently 
>>> running the app over and over. I tell you.. that is just nuts. Seriously 
>>> programmers?
>>>
>>> So, I had to figure out another way to execute my py file inside my py 
>>> script. Easy right? Ok, but I needed an argument.. so exec(open(read()) 
>>> wouldn't work.. or would it? Apparently this does:
>>>
>>> sys.argv = ["file.py"), vArguments]
>>> exec(open(os.path.join(wd,"tests","errorMessage.py")).read(), globals())
>>>
>>> Please note that I also included "globals()" there, because apparently exec 
>>> won't include any imports unless you do that. WTF? I'm... ambivalent about 
>>> Python at the moment. What are all these gotchas??
>>>
>>>
>>> On Sunday, 16 February 2020 16:23:18 

Re: [PyInstaller] Re: Pyinstaller: calling another Tkinter restarts the app and doesn't bring up other Toplevel() window.

2020-02-18 Thread JAY JAY
thank you for your message!! the main reason is not having the program be
an unweildy mess. The user interacts with variables that are used on
completely different pages, and it's just easier to compile them into
different scripts rather than one huge file.

My main problem was that this is the general assumption about python app
architecture? TK also is built around the idea that there should only be
one window. however I was trying to use the app to spit out tkinter error
messages whenever there was a user error. My main problem was not really
with pyinstaller but with not using Toplevel() as opposed to new instances
of tkinter. One of those gotchas.

In a similar way pyinstaller I guess assumes that you'll have one file?
Maybe I'm just a newb but I love modularity.

So, after I figured out I had to add all of these individual files or
directories via the spec file, I can definitely compile it all under one
bundle, which will go different places depending on which scripts are
activated. Took me a bit but now it's more of a package app rather than a
single use tool. I like your idea on sharing libraries between apps though,
I will investigate!!

thank you again for being kind and sharing ur thoughts!

On Mon, Feb 17, 2020, 4:16 PM 'Chris Barker' via PyInstaller <
pyinstaller@googlegroups.com> wrote:

> I think you need to rethink a bit what you are doing here:
>
> You are calling a python program from within a python program? Why? Do you
> need two programs running?
>
> If you do have a good reason, then you need to rethink how you are using
> PyInstaller (and maybe it's not the right tool).
>
> PyInstaller is designed to make ONE single application out of a pile of
> Python code. It sounds like you need two (or more?) applications. In which
> case, I think there are ways to make multiple top level programs that share
> the same libs, etc. Do a little googling, I can't find it at the moment,
> but it is possible, if not well tested.
>
> -CHB
>
>
>
>
>
>
> On Mon, Feb 17, 2020 at 12:29 AM JAY JAY  wrote:
>
>> Yeah soo.. I figured out my problem. BONKERS.
>>
>> Turns out I was using this:
>>
>> subprocess.call([sys.executable,"file"])
>>
>> AAAND.. if you run the python script without pyinstaller, sys.executable = 
>> the python interpreter. In a bundled pyinstaller app, that's NOT WHAT IT 
>> IS!!! It's actually the executable file itself. So, I was inadvertently 
>> running the app over and over. I tell you.. that is just nuts. Seriously 
>> programmers?
>>
>> So, I had to figure out another way to execute my py file inside my py 
>> script. Easy right? Ok, but I needed an argument.. so exec(open(read()) 
>> wouldn't work.. or would it? Apparently this does:
>>
>> sys.argv = ["file.py"), vArguments]
>> exec(open(os.path.join(wd,"tests","errorMessage.py")).read(), globals())
>>
>> Please note that I also included "globals()" there, because apparently exec 
>> won't include any imports unless you do that. WTF? I'm... ambivalent about 
>> Python at the moment. What are all these gotchas??
>>
>>
>> On Sunday, 16 February 2020 16:23:18 UTC-6, JAY JAY wrote:
>>>
>>> I have an app like this
>>>
>>> Main.py (includes root and Tk.Toplevel()) -- PythonDataProcessing.py --
>>> tkinterErrorMessage.py (includes another Tk.Toplevel()).
>>>
>>> When I run this on my computer via python main.py, the initial toplevel
>>> window opens, and any subsequent error message pulls up toplevel windows as
>>> expected. When I put it all through Pyinstaller and run the app, instead of
>>> a tkinter toplevel error message, I get initial main.py toplevel window,
>>> almost like the program is running itself again. WTF?
>>>
>>> I suspect this has to do with hooks in some way? Has anyone run into
>>> something like this? Wtf is going on? Like they say.. NOTHING IS EASY!
>>> Thanks for your help!
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "PyInstaller" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to pyinstaller+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/pyinstaller/4aa122fb-a375-4f52-9a6e-a6507dbe695a%40googlegroups.com
>> 
>> .
>>
>
>
> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR(206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115   (206) 526-6317   main reception
>
> chris.bar...@noaa.gov
>
> --
> You received this message because you are subscribed to the Google Groups
> "PyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pyinstaller+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> 

Re: [PyInstaller] Re: Pyinstaller: calling another Tkinter restarts the app and doesn't bring up other Toplevel() window.

2020-02-17 Thread 'Chris Barker' via PyInstaller
I think you need to rethink a bit what you are doing here:

You are calling a python program from within a python program? Why? Do you
need two programs running?

If you do have a good reason, then you need to rethink how you are using
PyInstaller (and maybe it's not the right tool).

PyInstaller is designed to make ONE single application out of a pile of
Python code. It sounds like you need two (or more?) applications. In which
case, I think there are ways to make multiple top level programs that share
the same libs, etc. Do a little googling, I can't find it at the moment,
but it is possible, if not well tested.

-CHB






On Mon, Feb 17, 2020 at 12:29 AM JAY JAY  wrote:

> Yeah soo.. I figured out my problem. BONKERS.
>
> Turns out I was using this:
>
> subprocess.call([sys.executable,"file"])
>
> AAAND.. if you run the python script without pyinstaller, sys.executable = 
> the python interpreter. In a bundled pyinstaller app, that's NOT WHAT IT 
> IS!!! It's actually the executable file itself. So, I was inadvertently 
> running the app over and over. I tell you.. that is just nuts. Seriously 
> programmers?
>
> So, I had to figure out another way to execute my py file inside my py 
> script. Easy right? Ok, but I needed an argument.. so exec(open(read()) 
> wouldn't work.. or would it? Apparently this does:
>
> sys.argv = ["file.py"), vArguments]
> exec(open(os.path.join(wd,"tests","errorMessage.py")).read(), globals())
>
> Please note that I also included "globals()" there, because apparently exec 
> won't include any imports unless you do that. WTF? I'm... ambivalent about 
> Python at the moment. What are all these gotchas??
>
>
> On Sunday, 16 February 2020 16:23:18 UTC-6, JAY JAY wrote:
>>
>> I have an app like this
>>
>> Main.py (includes root and Tk.Toplevel()) -- PythonDataProcessing.py --
>> tkinterErrorMessage.py (includes another Tk.Toplevel()).
>>
>> When I run this on my computer via python main.py, the initial toplevel
>> window opens, and any subsequent error message pulls up toplevel windows as
>> expected. When I put it all through Pyinstaller and run the app, instead of
>> a tkinter toplevel error message, I get initial main.py toplevel window,
>> almost like the program is running itself again. WTF?
>>
>> I suspect this has to do with hooks in some way? Has anyone run into
>> something like this? Wtf is going on? Like they say.. NOTHING IS EASY!
>> Thanks for your help!
>>
> --
> You received this message because you are subscribed to the Google Groups
> "PyInstaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pyinstaller+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pyinstaller/4aa122fb-a375-4f52-9a6e-a6507dbe695a%40googlegroups.com
> 
> .
>


-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyinstaller+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/CALGmxELiuCT1M9T9wwxY7aJ8O3zGHED9POrXD7-bXFJFj9VvRA%40mail.gmail.com.