Programming Advice

Sort:
Avatar of skelos

Whatever happened to the idea of "edit source code, compile if necessary, run"? I'm a dinosaur, and I suppose emacs could be considered an IDE anyway, so perhaps I'm not even a consistent dinosaur. sad.png

Avatar of Christopher_Parsons
skelos wrote:

Whatever happened to the idea of "edit source code, compile if necessary, run"? I'm a dinosaur, and I suppose emacs could be considered an IDE anyway, so perhaps I'm not even a consistent dinosaur.

I am with you. I remember typing run on a T.I. Lol...

I just want a run button that runs my code. 

Avatar of skelos

I type on the command line or double-click or something, but as noted, I'm not a Windows guy. Do you have an example "Hello, world" script? It's Sunday, I can experiment a little ...

Avatar of Christopher_Parsons
skelos wrote:

I type on the command line or double-click or something, but as noted, I'm not a Windows guy. Do you have an example "Hello, world" script? It's Sunday, I can experiment a little ...

I found one, but it was for the latest Python. I would have to look it up. It was also showing how to make a button with tkinter in a particular version of Python. It is a bit over my head. I was simply trying to make a string and print it, just to get the feel of the GUI.

my_first_time = "maiden voyage"

print  my_first_time

# Should print maiden voyage

Avatar of skelos

Yeah, OK ... adding in Tk (haven't used that for years, and then only played with it) will add some complexity. GUIs. sad.png See where I get to ... 64 bit Python from python.org, Notepad++ (well, why not). But Tk ... later ...

Avatar of Christopher_Parsons
skelos wrote:

Yeah, OK ... adding in Tk (haven't used that for years, and then only played with it) will add some complexity. GUIs.  See where I get to ... 64 bit Python from python.org, Notepad++ (well, why not). But Tk ... later ...

It's cool. I understand. I really appreciate you making an effort though. I was actually hoping a Python programmer would help me. happy.png

Avatar of skelos

Well, one may, and by some criteria I'm a Python programmer; I've been paid to write Python. Not with a GUI, however, but Tk is pretty sensible. Way more sensible than any other GUI I ever wrote code for, or considered writing code for!

Avatar of Christopher_Parsons
skelos wrote:

Well, one may, and by some criteria I'm a Python programmer; I've been paid to write Python. Not with a GUI, however, but Tk is pretty sensible. Way more sensible than any other GUI I ever wrote code for, or considered writing code for!

I am glad to hear that. I was looking forward to trying to expand and accelerate my education and push it towards the direction I want it to go anyway. It would help to have a practical application for what I am doing, instead of just learning things, to try to memorize them.

Avatar of skelos
#! /usr/bin/env python3

# Tinter "Hello World" example from:
# https://docs.python.org/3/library/tkinter.html
# Run command in Notepad++: py -3 "$(FULL_CURRENT_PATH)"

import tkinter as tk

class Application(tk.Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.hi_there = tk.Button(self)
        self.hi_there["text"] = "Hello World\n(click me)"
        self.hi_there["command"] = self.say_hi
        self.hi_there.pack(side="top")

        self.quit = tk.Button(self, text="QUIT", fg="red",
                              command=root.destroy)
        self.quit.pack(side="bottom")

    def say_hi(self):
        print("hi there, everyone!")

root = tk.Tk()
app = Application(master=root)
app.mainloop()
Avatar of Christopher_Parsons

I was told to put this into the pop up box after hitting the Run tab :

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib-r "$(FULL_CURRENT_PATH)"

then select a set of keys ex ctrl + alt + 1 and every time I hit f5, it would run my code. I tried several variations of people stating there were reasons to do it differently for different versions. One thing that none of them showed was an example of what happens if the Python is downloaded through visual studio. I think that is probably the problem.

Avatar of skelos

The above runs for me on both Windows 10 and OS X 10.11.6 (El Capitan).

In both cases it's as basic as can be: the Windows version uses a command shell for its output; the OS X version prints to the terminal window I ran the script from.

In Notepad++ Run->Run lets you set a hotkey to run the command after you define it.

 

Learning a language and a GUI together makes sense when you are going to need a GUI in the end, but you are learning two things.

Tk was originally designed in parallel with Tcl, a small "glue" language that later took on airs of grandeur. Or at least John Ousterhout, who is owed much for showing that a GUI could be done with containers and wasn't irredeemably tied for all time to objet oriented languages, pushed Tcl use far beyond what was sensible or a language you can't even run a syntax check for!

Tk has survived, Python from around the same time has survived, Perl from prior and Ruby from later have survived, and PHP of course doesn't care about GUIs because it (mostly) lives in web pages.

Which brings around an idea:

a) Do you know how to build web pages?

b) Could you use a web interface?

I've cheated a couple of times and used a web interface and later decided that in those cases it was the right choice anyway; no code to distribute, immediate cross-platform availability and low network requirements (which mattered for one of those applications, as people were still using dial-up connections in the early days).

Best wishes and good luck!

Avatar of skelos

I see we posted at the same time. Sounds like you're on the right track. I'd be looking for a "py" executable I think instead of "idelib" but perhaps that command is oddly named.

But as I said, good luck, and I think I'll bow out now and go and do some team admin work.

Avatar of Christopher_Parsons
skelos wrote:

I see we posted at the same time. Sounds like you're on the right track. I'd be looking for a "py" executable I think instead of "idelib" but perhaps that command is oddly named.

But as I said, good luck, and I think I'll bow out now and go and do some team admin work.

Thanks for your time and advice. 

Avatar of skelos

Yeah, showing output might not be a bad idea. Let me do that.

... time passes ...

OS X, the full window for the Tk pop-up and a selection of the terminal window:

null

null

 

Windows:

null

null

 

Done. As noted, basic, not pretty, but a working example. If you can get that far, you'll be on the way I trust.

Avatar of Christopher_Parsons
skelos wrote:

Yeah, showing output might not be a bad idea. Let me do that.

... time passes ...

OS X, the full window for the Tk pop-up and a selection of the terminal window:

 

 

 

Windows:

 

 

 

Done. As noted, basic, not pretty, but a working example. If you can get that far, you'll be on the way I trust.

What IDE are you using ?

Avatar of skelos

I don't regularly use one. For that test, Notepad++ which you'd mentioned as trying it was easy and I want no part of MS Visual Studio. Waaaay to big to cope with.

When I did have to program Windows last (hired for one job, had to do another) we had a non-interactive build environment to build everything. I forget how long it took ... an hour maybe from a clean start? Fortunately a clean start was seldom necessary, but it wasn't a five minute process either.

Avatar of Christopher_Parsons
skelos wrote:

I don't regularly use one. For that test, Notepad++ which you'd mentioned as trying it was easy and I want no part of MS Visual Studio. Waaaay to big to cope with.

When I did have to program Windows last (hired for one job, had to do another) we had a non-interactive build environment to build everything. I forget how long it took ... an hour maybe from a clean start? Fortunately a clean start was seldom necessary, but it wasn't a five minute process either.

My notepad++ looks different. Yours seems more streamlined. Here is a pic of mine running on windows 7 Pro x 64

null

Avatar of skelos

I didn't show mine, just the program running. That window capture looks pretty similar. Question is, with a different Python installation, what do you fill in as the run command? I don't think I can help with that, unless you find a "py" command lurking somewhere in your installation, in which case you might copy what I did ... scrolls back ... yes, I documented it within the script:

py -3 "$(FULL_CURRENT_PATH)"

Again, best of luck, but I'm out of ideas, unless you want to install the python.org Windows executable (default download is 32 bit, go to "Windows" downloads to get the 64 bit one) and continue with Notepad++.

Giles

Avatar of Christopher_Parsons
skelos wrote:

I didn't show mine, just the program running. That window capture looks pretty similar. Question is, with a different Python installation, what do you fill in as the run command? I don't think I can help with that, unless you find a "py" command lurking somewhere in your installation, in which case you might copy what I did ... scrolls back ... yes, I documented it within the script:

py -3 "$(FULL_CURRENT_PATH)"

Again, best of luck, but I'm out of ideas, unless you want to install the python.org Windows executable (default download is 32 bit, go to "Windows" downloads to get the 64 bit one) and continue with Notepad++.

Giles

I am thinking I want to get rid of that resource sucking Microsoft Visual Studio and just get the free standing version of Python. I tried at least 4 different cmd/paths for the run function's execution.

 

C:\ProgramFiles(x86)\MicrosoftVisualStudio\Shared\Python36_64\Lib\idlelib-r "$(FULL_CURRENT_PATH)"

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib-i "$(FULL_CURRENT_PATH)"

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib\idle.bat-r "$(FULL_CURRENT_PATH)"

 

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib\idle.bat-i "$(FULL_CURRENT_PATH)"

 

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib\idle.py-r "$(FULL_CURRENT_PATH)"

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib\idle.py-i "$(FULL_CURRENT_PATH)"

 null

Avatar of Christopher_Parsons

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Lib\idlelib\idle.py "$(FULL_CURRENT_PATH)"

null