def test_tkinter_lib():
    try:
        from PIL import Image
        from svglib.svglib import svg2rlg
        from reportlab.graphics import renderPM
        import PySimpleGUI as sg
        import re
    except Exception:
        print(
            "\n!!!!! Looks like you are missing required python packages. Please look at requirements.txt !!!!"
        )
        exit(1)
    try:
        import tkinter
        tkinter_version = tkinter.Tcl().eval('info patchlevel')
        print("Installed tkinter_version: %s \n %s" %
              (tkinter_version, "-" * 100))
        print('Opening test window. Click on "Quit" to run further tests')
        tkinter._test()
    except Exception:
        print(
            "\n!!!!! Looks like you are missing required 'tkinter' python package !!!!"
        )
        print("Try installing looking at following resources:")
        print("1. https://tkdocs.com/tutorial/install.html#install-win-python")
        print(
            "2. https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter"
        )
        print()
        exit(1)
Ejemplo n.º 2
0
import tkinter
tkinter._test()
Ejemplo n.º 3
0
import tkinter as tk

tk._test()
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import tkinter
>>> import _tkinter
>>> tkinter._test()
>>> 
 RESTART: C:\Python35\Python3 - Tech Academy\Tkinter_Exercise Files\Ch01\05_hello_tkinter.py 
>>> from tkinter immport *
SyntaxError: invalid syntax
>>> from tkinter import *
>>> from tkinter import ttk
>>> root = Tk()
>>> button = ttk.Button(root, text = 'Click me')
>>> button.pack()
>>> button['text']
'Click me'
>>> button['text'] = 'Press Me'
>>> button.config(text = 'Push Me')
>>> button.config()
{'image': ('image', 'image', 'Image', '', ''), 'style': ('style', 'style', 'Style', '', ''), 'cursor': ('cursor', 'cursor', 'Cursor', '', ''), 'padding': ('padding', 'padding', 'Pad', '', ''), 'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', 'ttk::takefocus', 'ttk::takefocus'), 'state': ('state', 'state', 'State', <index object: 'normal'>, <index object: 'normal'>), 'underline': ('underline', 'underline', 'Underline', -1, -1), 'default': ('default', 'default', 'Default', <index object: 'normal'>, <index object: 'normal'>), 'compound': ('compound', 'compound', 'Compound', <index object: 'none'>, <index object: 'none'>), 'class': ('class', '', '', '', ''), 'width': ('width', 'width', 'Width', '', ''), 'command': ('command', 'command', 'Command', <bytecode object: ''>, <bytecode object: ''>), 'textvariable': ('textvariable', 'textVariable', 'Variable', '', ''), 'text': ('text', 'text', 'Text', '', 'Push Me')}
>>> str(button)
'.2059962408520'
>>> str(root)
'.'
>>> ttk.Label(root, text = 'hello Tkinter').pack()
>>> 
Ejemplo n.º 5
0
#!/usr/bin/python
#
# Copyright (C) 2013
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

import sys
if sys.version_info >= (3, 0):
    import tkinter as tk
else:
    import Tkinter as tk

tk._test()
Ejemplo n.º 6
0
pip3 install opencv-python  numpy pandas scipy matplotlib tensorflow scikit-learn
sudo apt-get install python3-tk

Installing collected packages: numpy, opencv-python, six, python-dateutil, pytz, pandas, scipy, setuptools, kiwisolver, cycler, pyparsing, matplotlib, wheel, keras-preprocessing, absl-py, gast, protobuf, werkzeug, grpcio, markdown, tensorboard, astor, termcolor, h5py, keras-applications, pbr, mock, tensorflow-estimator, tensorflow, scikit-learn
Successfully installed absl-py-0.7.1 astor-0.7.1 cycler-0.10.0 gast-0.2.2 grpcio-1.19.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 kiwisolver-1.0.1 markdown-3.1 matplotlib-3.0.3 mock-2.0.0 numpy-1.16.2 opencv-python-4.1.0.25 pandas-0.24.2 pbr-5.1.3 protobuf-3.7.1 pyparsing-2.4.0 python-dateutil-2.8.0 pytz-2019.1 scikit-learn-0.20.3 scipy-1.2.1 setuptools-41.0.0 six-1.12.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.15.2 wheel-0.33.1

https://docs.opencv.org/3.2.0/d5/d26/tutorial_py_knn_understanding.html
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.html
"""

import cv2
import numpy as np
import matplotlib.pyplot as plt
import tkinter as Tk

Tk._test()
# Feature set containing (x,y) values of 25 known/training data
trainData = np.random.randint(0,100,(25,2)).astype(np.float32)
# Labels each one either Red or Blue with numbers 0 and 1
responses = np.random.randint(0,2,(25,1)).astype(np.float32)
# Take Red families and plot them
red = trainData[responses.ravel()==0]
plt.scatter(red[:,0],red[:,1],80,'r','^')
# Take Blue families and plot them
blue = trainData[responses.ravel()==1]
plt.scatter(blue[:,0],blue[:,1],80,'b','s')
#plt.imshow("test.png")
plt.show()

# KNearest CV"
newcomer = np.random.randint(0,100,(1,2)).astype(np.float32)
Ejemplo n.º 7
0
# tkinter provides access to the tk widget toolkit
# this is a toolkit which lets you make gui programs
#
# the toolkit was designed for a language called TCL
# this module essentially takes that and interprets between python and TCL,
# but we don't need to worry about that directly
# what it does mean is that the documentation isn't great

try:
    import tkinter
except ImportError:  # python 2 version uses a different (capitalised) module name
    import Tkinter as tkinter

print(tkinter.TkVersion)
print(tkinter.TclVersion)

tkinter._test()  # creates a test gui

# defines window, with some properties
main_window = tkinter.Tk()
main_window.title("Hello World")
main_window.geometry(
    "640x480+200+200")  # window size and location on the screen

main_window.mainloop(
)  # opens the window by handing control over to tk to begin doing its event handling
Ejemplo n.º 8
0
pip3 install opencv-python  numpy pandas scipy matplotlib tensorflow scikit-learn
sudo apt-get install python3-tk

Installing collected packages: numpy, opencv-python, six, python-dateutil, pytz, pandas, scipy, setuptools, kiwisolver, cycler, pyparsing, matplotlib, wheel, keras-preprocessing, absl-py, gast, protobuf, werkzeug, grpcio, markdown, tensorboard, astor, termcolor, h5py, keras-applications, pbr, mock, tensorflow-estimator, tensorflow, scikit-learn
Successfully installed absl-py-0.7.1 astor-0.7.1 cycler-0.10.0 gast-0.2.2 grpcio-1.19.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 kiwisolver-1.0.1 markdown-3.1 matplotlib-3.0.3 mock-2.0.0 numpy-1.16.2 opencv-python-4.1.0.25 pandas-0.24.2 pbr-5.1.3 protobuf-3.7.1 pyparsing-2.4.0 python-dateutil-2.8.0 pytz-2019.1 scikit-learn-0.20.3 scipy-1.2.1 setuptools-41.0.0 six-1.12.0 tensorboard-1.13.1 tensorflow-1.13.1 tensorflow-estimator-1.13.0 termcolor-1.1.0 werkzeug-0.15.2 wheel-0.33.1

https://docs.opencv.org/3.2.0/d5/d26/tutorial_py_knn_understanding.html
https://docs.opencv.org/3.0-beta/doc/py_tutorials/py_ml/py_knn/py_knn_understanding/py_knn_understanding.html
"""

import cv2
import numpy as np
import matplotlib.pyplot as plt
import tkinter as Tk

Tk._test()
# Feature set containing (x,y) values of 25 known/training data
trainData = np.random.randint(0, 100, (25, 2)).astype(np.float32)
# Labels each one either Red or Blue with numbers 0 and 1
responses = np.random.randint(0, 2, (25, 1)).astype(np.float32)
# Take Red families and plot them
red = trainData[responses.ravel() == 0]
plt.scatter(red[:, 0], red[:, 1], 80, 'r', '^')
# Take Blue families and plot them
blue = trainData[responses.ravel() == 1]
plt.scatter(blue[:, 0], blue[:, 1], 80, 'b', 's')
#plt.imshow("test.png")
plt.show()

# KNearest CV"
newcomer = np.random.randint(0, 100, (1, 2)).astype(np.float32)
Ejemplo n.º 9
0
import tkinter as tk

a = tk._test()

a
# Author: Kristen Findley
# Version: Python 3.5.2
# Date: 16 January 2017
# Description: tkinter tutorial

import tkinter  # imports tkinter module
import _tkinter  # imports compiled binary associated w/ tkinter package
tkinter._test(
)  # use to test tkinter and show you which version of tck/tk is on your comp

from tkinter import *  # imports everything
from tkinter import ttk  # imports themed tkinter from separate module

root = Tk()  # create root window
button = ttk.Button(
    root, text='Click Me')  # creates themed button, but doesn't add to window
button.pack()  # packs button in root window
button['text']  # use to view text property of button
button['text'] = 'Press Me'  # use to change property of button
button.config(text='Push Me')  # other way to modify property
button.config()  # returns all properties of button in the form of tuples

ttk.Label(root, text='Hello, Tkinter!').pack(
)  # creates label with text property under root window and immediately packs it
Ejemplo n.º 11
0
import tkinter
import _tkinter

tkinter._test()  ## this the test routine for tkinter.
# if all run without error, you are good to go with tkinter.
Ejemplo n.º 12
0
#!/usr/bin/python
# -*- coding: UTF-8 -*-

#import Tkinter

import tkinter as tk

tk._test()  # 测试 tkinter 是否正常工作

# create root window
top_win = tk.Tk()

# naming root window
top_win.title('LiangBa Main Window')

# resize root window
top_win.geometry('800x600')

# generate a label
lbl_hello = tk.Label(top_win,
                     text='Hello world!',
                     bg='blue',
                     font=('Arial', 12),
                     width=30,
                     height=2)
# put lable onto window
#lbl_hello.pack()
lbl_hello.place()

# 进入消息循环
top_win.mainloop()
Ejemplo n.º 13
0
class ponto:
    "Classe que manipula cordenadas de pontos (x, y)"

    def __init__(self, cord_x=0, cord_y=0):
        "Cria um ponto na origem"
        self.x = cord_x
        self.y = cord_y

    def __str__(self):
        "Serve para imprimir na tela"
        return f"({self.x}, {self.y})"

    def getx(self):
        "Retorna a cordenada x"

        return self.x

    def gety(self):
        "Retorna a cornada y"

        return self.y


import tkinter

a = tkinter._test()
Ejemplo n.º 14
0
def do_test():
    tkinter._test()
Ejemplo n.º 15
0
# There are other graphic programs available but tkinter is part of python language

# Here are links for documentation for tkinter
# https://docs.python.org/2/library/tkinter.html
# http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/index.html
# http://www.tkdocs.com/
# https://en.wikipedia.org/wiki/Tk_(software)

# Now we will check to see if tkinter is installed properly with this python

import tkinter

print(tkinter.TkVersion)    # To check the version installed
print(tkinter.TclVersion)   # Also to check version

tkinter._test()   # To test tkinter is installed well. It pulls a GUI

print("="*40)

# importing tkinter in python 2 syntax

import tkinter # in python 3
# import Tkinter # in python 2. has a capital T

# if you don't know which python code you are running, you can use this command below
# to check and download tkinter in the correct syntax


try:
    import tkinter   # Try to see if you can import with tkinter (python 3 syntax)
except ImportError:  # if there is an ImportError (meaning you're running python 2 and it expects Tkinter (with cap T)