import tkinter as tk
import numpy as np
from pandas import DataFrame
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title("Display DataFrame")
self.df = DataFrame(np.arange(20).reshape(4,5))
for r in range(4):
for c in range(5):
e = tk.Entry(self)
e.insert(0,self.df.iloc[r,c])
e.grid(row=r,column=c)
e.bind("<KeyPress>",lambda event, row=r, column=c: self.change(event,row,column))
def change(self,event,row,column):
value = event.widget.get()
self.df.iloc[row,column] = value
print(self.df)
if __name__ == '__main__':
app = App()
app.mainloop()
import numpy as np
import math
from pandas import DataFrame
r1 = np.random.uniform(0.0, 1.0, 10000)
r2 = np.random.uniform(0.0, 1.0, 10000)
p = DataFrame([(x, y) for x, y in zip(r1, r2) if math.hypot(x, y) < 1])
print(4 * len(p) / 10000)
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0.0,2.0,0.001)
y = np.sqrt(1-x**2)
plt.figure(figsize=(5,5))
plt.xlim(0.0,1.0)
plt.ylim(0.0,1.0)
plt.plot(x,y)
plt.plot(p[0],p[1],'.')
import tkinter as tk
import tkinter.font as tkFont
from unicodedata import east_asian_width
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title("Font examples")
self.geometry("800x400")
for font_name in tkFont.names():
font = tkFont.nametofont(font_name)
frame = tk.Frame(self)
fw = 13 - len([c for c in font['family'] if east_asian_width(c) in 'AFW'])
tk.Label(frame,text=f"{font_name:18} {font['family']:{fw}s} {font['size']:2d} ",
font="TkFixedFont").pack(side=tk.LEFT)
tk.Label(frame,text="This is ascii text. 日本語だとこんな風に出力されます。",
font=font_name).pack(side=tk.LEFT)
frame.pack(side=tk.TOP, anchor=tk.W)
if __name__ == "__main__":
app = App()
app.mainloop()