Create a matrix with PythonGUI (text box)

It is a source to input the value of the matrix element with GUI (tkinter text box) and acquire the data of 2D array type. The matrix can be changed to any size by variables.

qiita.rb


from tkinter import *
from tkinter import ttk
import numpy as np

#GUI for input
def GUI_Input(n,m):

    root = Tk()
    root.title('Table Input')

    #Input frame
    frame = ttk.Frame(root)
    frame.grid(row=0, column=0)


    list_Items = [0]*(n*m)
    N = n
    M = m
    k=0
    for i in range(0, n):
        for j in range(0, m):


            list_Items[k] = ttk.Entry(frame,width=2)
            list_Items[k].grid(row=i+1, column=j+1)
            k+=1


    #Get data from a text box and print it out as a two-dimensional array
    def ButtonClicked_Run():
        B = [0]*(N*M)

        for i in range(N*M):
            B[i] = list_Items[i].get()

        A= np.reshape(B, (N,M))
        print(A)




    #Installation of execute button
    button_Run = ttk.Button(root,
                            text='Run',
                            padding=5,
                            command=ButtonClicked_Run)
    button_Run.grid(row=1, column=0)

    root.mainloop()


#n,Change the number of m to change the number of rows in the table

m = 9
n = 9
GUI_Input(m,n)

result Screenshot 2020-01-13 23.27.57.png

Screenshot 2020-01-13 23.28.37.png

Recommended Posts

Create a matrix with PythonGUI (text box)
Create a matrix with PythonGUI (tkinter combo box)
Create a python3 build environment with Sublime Text3
Create a homepage with django
Create a heatmap with pyqtgraph
Create a directory with python
Create a virtual environment with Python!
Create a poisson stepper with numpy.random
Create a file uploader with Django
Create a Python function decorator with Class
Build a blockchain with Python ① Create a class
Create a dummy image with Python + PIL.
[Python] Create a virtual environment with Anaconda
Let's create a free group with Python
Create a GUI app with Python's Tkinter
Create a star system with Blender 2.80 script
Create a virtual environment with Python_Mac version
Create a VM with a YAML file (KVM)
Create a simple web app with flask
Create a Python-GUI app in Docker (PySimpleGUI)
Create Excel file with Python + similarity matrix
Create a word frequency counter with Python 3.4
Create a Connecting Nearest Neighbor with NetworkX
Create a web service with Docker + Flask
Create a private repository with AWS CodeArtifact
Create a car meter with raspberry pi
Create a devilish picture with Blender scripts
Create a graph with borders removed with matplotlib
Create a frame with transparent background with tkinter [Python]
Speaking Japanese with OpenJtalk (reading a text file)
Create a GUI executable file created with tkinter
Speaking Japanese with gTTS (reading a text file)
Create a LINE BOT with Minette for Python
Create a virtual environment with conda in Python
Create a page that loads infinitely with python
"Inline" Sublime Text plugin callbacks with a generator
Create a bulletin board with Heroku, Flask, SQLAlchemy
Create a dashboard for Network devices with Django!
Create a color bar with Python + Qt (PySide)
Steps to create a Twitter bot with python
Create a new page in confluence with Python
Create a color-specified widget with Python + Qt (PySide)
How to create a Kivy 1-line input box
How to create a multi-platform app with kivy
Create a one-file hello world application with django
Create a Photoshop format file (.psd) with python
Create a Python console application easily with Click
Create a cylinder with open3d + STL file output
Create a "Hello World" (HTTP) server with Tornado
Create a translation tool with the Translate Toolkit
Create a table of contents with IPython notebook
Memo to create your own Box with Pepper's Python
Create a Todo app with Django REST Framework + Angular
I tried to create a table only with Django
Create a native GUI app with Py2app and Tkinter
How to create a submenu with the [Blender] plugin
Try to dynamically create a Checkbutton with Python's Tkinter
Convert a text file with hexadecimal values to a binary file
Create a virtual environment with Anaconda installed via Pyenv
[Python] Create a ValueObject with a complete constructor using dataclasses
Create a Todo app with the Django REST framework