Currently working on Python (version 3.7.8) programming, using PyCharm software.
I would like to install tkinter for future python projects with future and pip plugins.
I tried to follow a series of tutorials, but all I get is error messages, such as tracebacks.
Source code as follows:
import tkinter
top = tkinter.Tk()
top.mainloop()
Related
I wanna learn kivy. But on youtube, everyone run it by creating class and have to run it by classname().run(). I want to simplify to run kivy like tkinter, I always use root=Tk() to create and design window. Can anyone know how to use kivy like tkinter/root=Tk()??
Here is my code, which I always use with tkinter:
from tkinter import *
root=Tk()
root.title('Stackoverflow')
root.config(bg='white')
root.geometry('400x400')
Label(root,text='Welcome to This Question, Please Answer This',font='20',bg='white').place(x=30,y=170)
root.mainloop()
No, Kivy doesn't have the same API as tkinter and I'm not aware of anyone having written a wrapper package to expose a similar API.
Also, I would encourage you not to worry about this - it's normal that different packages have different APIs, and in general these APIs are designed to efficiently express how the toolkit should be used. It is normal to expect to learn how a new package works.
Installing Kivy
python -m pip install --upgrade pip setuptools virtualenv
python -m virtualenv kivy_program
kivy_program/Scrtips/activate
source kivy_program/Scripts/activate
source kivy_program/Scripts/activate
python -m pip install kivy[base] kivy_example
Code
from kivy.app import App
class myapp(App):
pass
# Code
if __name__ == '__main__':
window = myapp()
I just downloaded Pycharm because Spyder on Anaconda wasn't working anymore on my Mac. I am trying use Tkinter and have tried to run code using both
from tkinter import *
and
import tkinter as tk
The second is from my python class. Both times it returns
ImportError: No module named tkinter
I have tried to search for "tkinter" on Python Interpreter but there's no solid "tkinter." Only others like tkinter.math. Please help.
Tkinter would not be visible on Python Interpreter since it is a part of standard Python installation, the only additional modules or packages which user downloads are visible in Settings. Since, Spyder on your PC is not working as well, make sure python is installed properly and is configured correctly with path details properly set up.
I think you should check the interpreter of PyCharm.
Or Reinstall the python package and make a virtual environment.
I had been using Python2.7 on Windows 10 (64-bit). I recently decided to upgrade to 3.0 to update some legacy scripts.
I uninstalled Python27, and installed Python30 (I know I could supposedly run them concurrently on the same system, but I chose not to use that as a crutch) and updated the Windows %PATH%
My old scripts used ttk (import ttk).
I updated to use "from tkinter import ttk", but now I'm getting "cannot import name ttk". I'm assuming it's still somehow trying to link to the 2.7 Tkinter that no longer exists (and didn't contain ttk as a submodule since it was 2.7).
How can I get ttk to link correctly under Python3 after having used 2.7?
hey i'am new in programming ..
I am doing a mini project in python in pycharm..
I am getting an error which says Tkinter module not installed..
plzz anybody can help..!!
in case of Python3.6, tkinter is a part of the standard library available from when you install your python. However if you want to know if tkinter is installed just import it in the python console
import tkinter
if you didn't see any errors you are good to go.
I'll preface this by saying that I am aware that on 2.7 it should be:
import Tkinter
However, for whatever reason on my desktop running xenial and
python --version
returning:
python 2.7.12
I have had no trouble throughout the development of an application on my system importing tkinter with
import tkinter
I am wholly confused because as I went to work on a different machine I attempted to run my code only to find out I should have been using
import Tkinter
Which executes fine on the second machine. However,
import tkinter
returns that there is no module named tkinter.
Does anybody know why this is happening?
You must have installed the six module at some point. It includes a dummy tkinter that allows python3 style tkinter imports in python2.