Python Forum
[Tkinter] how do I enter code into python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [Tkinter] how do I enter code into python (/thread-8278.html)

Pages: 1 2


how do I enter code into python - matelot - Feb-13-2018

I am totally new to python. I have been asked to use python to solve another problem
I have gone through
https://python-forum.io/Thread-Basic-How-to-Execute-python-code
without the answer.
From there I have deduced that I must build a file using something like wordpad, this I have done.
I now have a file called test.py containing.

## Rubik (Hello, World)    @ kas 2017

from tkinter import *
import serial, time
from serial import SerialException
import atexit
import subprocess

root =Tk()
root.title('Hello, World')
root.geometry('300x300+200+200')          

## window size + position

root.mainloop()
I have looked up tkinter and found it is a file that is included in the python download.
I am not sure about 'serial' is this within tkinter?
When I put c;users\bob\test.py (that is where the file is) into python all I get is
SyntaxError; unexpected character after line continuation character.
I assume I am doing something simple wrong but I have no idea what. Can you help?
thanks.


RE: how do I enter code into python - buran - Feb-13-2018

https://python-forum.io/Thread-Basic-How-to-Execute-python-code is pretty clear how to run it
c:\Users\bob>python test.py


RE: how do I enter code into python - Gribouillis - Feb-13-2018

You don't need lines 4,5,6,7. You can run the code by typing
Output:
python C:\Users\bob\test.py
in a terminal (use the correct path). You can also read this official documentation page: Using python on Windows

I'm not a windows user, but I know that you must not use a word processor that produces rich text to write python code. Wordpad may not be the correct tool. Install a real editor such as Notepad++ for this.


RE: how do I enter code into python - buran - Feb-13-2018

(Feb-13-2018, 08:27 AM)Gribouillis Wrote: I'm not a windows user, but I know that you must not use a word processor that produces rich text to write python code. Wordpad may not be the correct tool. Install a real editor such as Notepad++ for this.
Oh, I didn't notice OP is using Wordpad :-(


RE: how do I enter code into python - matelot - Feb-13-2018

(Feb-13-2018, 08:16 AM)buran Wrote: https://python-forum.io/Thread-Basic-How-to-Execute-python-code is pretty clear how to run it
c:\Users\bob>python test.py
Sorry buran I don't find the page you mention at all 'clear' for running python.
I will stick to the part
Command line (python script)
I have saved a file, my file is called ‘test’ because I used the page you mention to help me try to get it to work.
I have located the directory of the file and entered it into the command line
C:users\bob\test.py, as I said in my first post all I get is
SyntaxError; unexpected character after line continuation character.
A little further down the same page it says
Does your program when executed just flicker and then go away?.....in python 3. put input() in the end of the file to prevent this.
I tried this and it doesn’t work, my program still flickers and goes away if I just double click on the file.
It also says It depends on what OS you are on as to what the commands are. Some basics are:
Cd something
If I put cd user to change the directory to user it ignores this as well.

Grigouillis
Most of Your link is concerned with installing and altering various forms of python.
At one point (3.4.1 getting started) it does say
To check that the launcher is available, execute the following command in Command Prompt: py
if I do that I get
Traceback (most recent call last):
File "<stdin>". Line 1. in <module>
NameError: name 'py' is not defined
I assume I am not even in the launcher but nowhere, I can find, does it say how to check or how to get into the launcher.
At the top of the box it does say
python 3.6.4 (v3.6.4:d48eceb. Dec 19 2017, 06:04:45) [MSC v.1990 32 bit (intel)]
So I am assuming that I am at least somewhere in the python world.

I am not using wordpad. I said
Quote:I have deduced that I must build a file using something like wordpad
in fact I am using notepad.


RE: how do I enter code into python - buran - Feb-13-2018

As Grigouillis suggested - don't use wordpad, but simple Notepad or other simple editor like Notepad++
Then on commad line just enter
(Feb-13-2018, 08:16 AM)buran Wrote: c:\Users\bob>python test.py



RE: how do I enter code into python - Gribouillis - Feb-13-2018

(Feb-13-2018, 11:19 AM)matelot Wrote: SyntaxError; unexpected character after line continuation character.
You may have this because you created the file with wordpad. This is a word processor, not a text editor.


RE: how do I enter code into python - matelot - Feb-13-2018

I am using notepad.


RE: how do I enter code into python - buran - Feb-13-2018

can you post a screenshot of what you are doing?


RE: how do I enter code into python - matelot - Feb-13-2018

[Image: enhance]
[Image: enhance]