How do i change the console title of a python script like console.title in c# - python-3.x

Is there a way to change title of a console based py program? so when i convert it to exe it'd show as "Test - v.1.5"
without using tkinter, kivy etc

found it
import os
os.system("title XYZ")

Related

Python Tkinter: Run python script when click button_widget of tkinter and keep value from return variables

I am new with GUI programming in Python 3.x with Tkinter.
I have prepared a GUI where user needs to select options (using OptionMenu widget) and after selection press button to run the final program.
I have saved the user selected data into variables in that GUI program.
But don't know what should I do next...
What I want:
That GUI should be hidden or End after pressing the button.
Run another python script and use those saved variables from that GUI in my script.
How it can be done in python.
You can save your data in another file in order to use it in other script with pickle module.
To save you can do a list with all the variables you want:
import pickle
with open('doc_name.txt','wb') as a:
pickle.dump(saved_variable_list,a)
And in another python script you can use that list of variables:
import pickle
with open('doc_name.txt','rb') as a:
saved_variable_list = pickle.load(a)
Finally to close your GUI you can use the 'destroy' command:
root.destroy()

How can i open a file using a python script i coded?

I would like to open a file such as an image file using a python script, and by doing so, pass the file name and location into the script when i choose to open the image in my script.
clicks "open image in another program" in windows 10
import tkinter as tk
filename = fileopen.name()
filelocation = fileopen.path()
window = tk.Tk()
imagepic = tk.PhotoImage(file=filelocation)
picture = tk.Label(window, image=imagepic)
window.mainloop()
I'm pretty sure theres a module that allows for this but i just cannot find it.
I'm not entirely sure I understood your question correctly, but for dealing with the operating system you would use the module os:
import os
os.startfile(filelocation) # Open file in win10 default program
What I meant originally was how to go about registering a context menu option in windows explorer allowing the user to right click a file and select "Open with " - passing the file into the script as an argument.
In order to achieve this, you can follow this guide, supplying this command:
python -m <absolute/path/to/yourscript> %1
The %1 will be the file as an argument.

Python doesnt respond after calling filedialog.askopenfilename() from TK

this is my first question:
Im looking to implement a interactive way to look for a path and then load the data frame with pandas.
Im using Tk, when i run the code it seems like the terminal is running a infinite loop.
`import tkinter as tk
from tkinter import filedialog
root = tk.Tk()
root.withdraw()
file_path_to_open = filedialog.askopenfilename()`
where is my error ? any advice? im looking for something similar to uigetfile from MATLAB in python.
I don't know whether this answer is still useful for you, but maybe for those people having the same issue and coming here via google:
The issue is not caused by the piece of code itself, because that is working fine. See also Quick and easy file dialog in Python?
I assume it is caused because of some background tk processes which were not closed cleanly.
My solution was to restart the python kernel (using Jupyter Notebook with python 3.6) and reimporting. Also, it might help to close all background python processes, which might be still running, via the task manager.

what to type on a text editor find-and-replace to port python 2 prints to python3

I am trying to make this open source project to run in python 3.
So far the only fix is to replace print whatever to print(whatever)
Is there any way to tell the find and replace tool of pycharm to do this?
Don't use a text editor for this. Use 2to3 instead. It comes with Python.

Python py2exe with tkinter (pyw file)

I have made a small program in Python that involves tkinter, and I made it a pyw file because it has a shortcut on the desktop and I do not want the command prompt to get in the way. I used py2exe following the sentdex tutorial on youtube, and I got an output file, but the output file shows an error and exits before I can read it. The pyw file on its own works fine, but I don't know how to get the exe output file to work correctly.
Information:
Python - 3.4.2;
OS - Windows 8.1;
Folder - Multiple items (photos and audio for the program);
Program - A simple animation in tkinter
If you need the program, tell me and I can upload the folder containing the program.
As far as I understand there is not a version of py2exe for python3.x
You'd be best of going for cx_freeze (Sentdex also has a tutorial on that on that)

Resources