首页 > 解决方案 > 经济学应用。我的原始申请

问题描述

当我运行程序时,我的程序给了我一个错误,说当我只传递了两个参数时,我将 3 个参数传递给了 top.geometry(x,y)。

I've tried using "foo" and that made it worse. What I am trying to do is create a tkinter application that will calculate the amount of money adjusted for inflation at a future year.

    #!/usr/bin/env python3
    import tkinter as tk
    from tkinter import *
    import math
    from math import *
    import matplotlib 
    from matplotlib import *
    from pylab import plot, show

    "set window geometry variables"
    (x,y) = (1650,1100)
    "Define Empty List"
    x_Data = []
    y_Data = []
    "Create Window and Define it's Size"
    top = tk.Tk()
    top.title("Inflation Adjusted Calculator")
    top.geometry(x,y)




Traceback (most recent call last):
  File "/home/jacob/Documents/Python Programs/Inflation_Calculator_Program.py", line 17, in <module>
    top.geometry(x,y)
TypeError: wm_geometry() takes from 1 to 2 positional arguments but 3 were given

标签: pythontkinterpython-3.6

解决方案


的定义geometry如下

将几何图形设置为 =widthxheight+x+y 形式的 NEWGEOMETRY。如果给出 None,则返回当前值。

因此,要将窗口的值设置为 1650x1100,您只需将其传递给geometry方法即可。

import tkinter as tk
from tkinter import *
import math
from math import *
import matplotlib 
from matplotlib import *
from pylab import plot, show

# Define Empty List
x_Data = []
y_Data = []
# Create Window and Define it's Size
top = tk.Tk()
top.title("Inflation Adjusted Calculator")
top.geometry('1650x1100')
mainloop() 

推荐阅读