I'm quite new to linux, raspberry, tkinter and python and therefore I need some guidance to get on the right track.
I'm running Arch Linux on a raspberry pi and I want a quite fast loaded gui for my project. I have decided to go with tkinter. I have installed xorg and some other needed xorg packages, and when I run "startx" I get three windows and a litte clock with some green/blue colored borders and i can move the widows with drag and drop. If I run my tkinter py-file from any window it works just fine.
I came over the "xinit" command and this loads a little faster and just gives me one window without borders. This actually suits me better since my "base window" will work as some kind of desktop and from here I will pop up other windows. Since there's no borders or title bars on the windows, they are not moveable. Is there any way to achieve this? That is, I want just some windows to have a border and a title bar.
And; how can I run the tkinter py-file automatically when I run the xinit/startx? I have tried the other approach by run the xinit/startx in the pyfile, but this does not work. I guess this will be called as some kind of sub command in another thread, or something? Any suggestions how I do this?
Related
root.attributes("-transparentcolor", "white") won't work with a .pyw file extension
Up until yesterday all my tkinter GUIs have been working like they should but two days ago all of them stopped working like I want them to. The line root.attributes("-transparentcolor", "white") has always made the white color transparent, like it should, but now it doesn't work like it used to. It does work properly if I launch the program with a .py file extension but not with a .pyw. Obviously I don't want a console window to open along with all of my programs so this is not something I could just accept. Like I said, this has worked fine up until yesterday.
For the past day I've been doing all kinds of things to try to fix this, I even uninstalled python completely and reinstalled the latest version, but nothing has changed my problem.
I'm on Windows 10 and python 3.9.1 right now (after the reinstall, can't remember what version I had before)
I didn't do a single thing that could've made this happen, I didn't update or change anything before my problem showed up, I simply started my computer in the morning like always.
Does anyone have any clue on what I could try? Could anyone try to do the same thing and see if it works for you?
Code below creates a tkinter window with a transparent background if saved as a .py file, but creates a tkinter window with white background if saved like a .pyw file.
from tkinter import *
root = Tk()
root.config(bg= 'white')
root.attributes('-transparentcolor', 'white')
root.mainloop()
Update:
Hmm... I've discovered something interesting!
If I start my program through cmd prompt with pythonw my problem still appears, but if I do the same thing with a cmd prompt running as administrator it all works like before, I get a transparent background!
Update 2:
I've set pythonw.exe to always run as administrator, and this solves my problem. But if I do that I always get a uac prompt which I never got before, so I haven't fixed my problem, I've just found a tedious workaround.
Allrighty then... I've found a solution, even though I do not like it. I don't have anything against windows or Microsoft, but I really do not like the Microsoft store. But I have to give in, this does solve my problem:
I went and installed python 3.9 from the Microsoft store. I do not know why I did it. I do not know why it helped. I started my .pyw file with the installed program/app called "Python 3.9 (Windowed)" and badaboom, badabing, my problem for some frickin reason, disappeared...
I don't know if this is a viable solution long term (or at all for that matter) but it solves my problem, and after 2 days of continuously smashing my head against the keyboard and wanting to set my pc on fire, I have to accept this as a solution and move on...
Thank u #acw1668 and #martineau for trying to help, I really appreciate it!
Tl;dr:
Download python from Microsoft store and use that program to start the file
I am learning Python (v 3.7) on a Mac using PyCharm. As I practice using the turtle library, the program runs without error, outputs the correct graphics, but then the graphics screen disappears immediately after the code completes runnning. Adding time.sleep(5) at the end of my program persists it and also shows that the focus changed from PyCharm to a Python program menu (which I can't find or turn on in the hope of keeping running).
When I use Thonny, the output persists, so I can check my work. How can I make it persist in PyCharm?
A well-structured Python turtle program will end with a call to mainloop() or one of its variants (exitonclick(), done()) This turns control over to the underlying tkinter event handler which will keep your window open, awaiting user events. Without this, the program simply ends and the window closes.
You don't need time.sleep() nor input("Press Enter to continue..."). Some Python programming environments clash with mainloop() but even those tend to disable it behind the scenes so the same code works everywhere.
First, do not use PyCharm to test. If you like it, more power to you, but personally, I have had many issues with output and PyCharm. Learn the command line, since you are using Mac. CodeAcacdemy and LinuxJournery have really good resources on that subject. Second, if you are still having issues, please reinstall trutle, Python 3.7 (there were some issues wiht it displaying on Mac), and macOS itself. Have a great day!
https://linuxjourney.com/
https://www.codecademy.com/learn/learn-the-command-line
Problems getting pygame to show anything but a blank screen on Macos Mojave
I am using Spyder with Anaconda Launcher.
I was working on some machine learning models and when drawing graphs, I used X_grid = np.arange(min(X), max(X), 0.00000001)
Now the problem is that 0.00000001 takes a LOT of time to execute. Ideally people don't exceed 0.001.
Because of this, there is one process called "python" always showing up in the dock. If I force quit it, the kernel in Spyder dies and restarts and it instantly shows up in the dock again.
The python process icon in the dock looks like this.
I tried googling a lot, checking out answers in stackoverflow but none helped. I also tried completely removing anaconda from my mac, deleting the anaconda folder from the Users folder, then restarting the mac and then reinstalling it. Nothing seems to work! And it is really annoying to see that white icon in the dock.
So can anyone help me get rid of that white python process icon from the dock?
EDIT: I seem to have found the problem. Whenever I try to plot a graph using matplotlib, it used to appear in the console but the process icon used to not appear. To make the graph appear in a separate window, I go to Preferences > IPython Console > Graphics and select Automatic under 'Graphics Backend'. When I do this, this annoying icon appears again! Any help is appreciated.
I've recently written a shell script which boots my Windows Python application with wine:
#!/bin/sh
wine data/Python/x86/python.exe loader.py 'x86'
While the program is running, everything works as expected. The problem is, when the SDL window is displayed, my second monitor is disabled, and the orientation of my primary monitor changes. The resolution of my primary monitor stays the same. My question is, what can I do to disable these changes?
Installing a Linux Python interpreter is out of the question, because the solution:
1: needs to be portable
2: would currently oversize download
EDIT:
some extra info, I just recently ran it with a terminal and got:
fixme:win:EnumDisplayDevicesW ((null),0,0x42f3ec,0x00000000), stub!
fixme:win:EnumDisplayDevicesW ((null),0,0x42f46c,0x00000000), stub!
fixme:wgl:X11DRV_wglChoosePixelFormatARB unused pfAttribFList
not sure if this solves anything though
If you run winecfg you can set it to run all applications in a window. From http://ubuntuforums.org/showthread.php?t=693292
Applications --> Wine --> Configure Wine or just run winecfg from the
terminal
Click on the Graphics tab Check the "Emulate Virtual Desktop" box And
enter in the virtual Desktop size (like 800x600 or something).
It sounds like your pygame application is setting a resolution and switching to fullscreen. If you could disable fullscreen in the pygame app, this would probably also work.
Well, I've used it long enough to verify this was the case.
I'd not even used linux for a month before posting this question.
The issue happened because of Wine version 1.6 incompatibilities.
The solution is to update Wine.
I have two questions about pygame and python:
One: It is using pygame in fullscreen mode and I was wondering how I can get other windows (google chrome, Safari, Mail, Thunderbird, Itunes) to go on top of the already fullscreen window. Two: Can I make Python install all the modules that the custom desktop will need without the user having to go and install them all themselves
Just make a borderless screen that is the size of your desktop excluding the start menu etc. For the second question, just compile so the user doesn't need python. I have done this quite easily with py2exe, assuming you are running windows, I have heard py2app is good for mac, py2exe cant really be used easily on linux but with wine its programs seem to run fine.