什么是Cookie Clicker
Cookie Clicker 是2013年Orteil发布的一款网页放置类游戏,去年登上Steam后爆火。今天,我将用Python的tkinter,还原cookie clicker,做一款Apple clicker!
Cookie Clicker网页版地址:Cookie Clicker
Github 开源!
模块下载
使用pip下载所有所需模块:
pip install cryptocode
pip install tkinter
pip install ttkbootstrap
完整代码
import sys # 导入模块
import threading
import time
import cryptocode
import tkinter as tk
from tkinter import *
from tkinter import ttk
from ttkbootstrap import Style
ver: str = 'beta0.2.0' # 版本号
apple_amount: int = 0 # 初始化定义
apple_amount_total: int = 0
sponsor_amount: int = 0
seed_amount: int = 0
basket_amount: int = 0
tree_amount: int = 0
garden_amount: int = 0
town_amount: int = 0
country_amount: int = 0
planet_amount: int = 0
wizardtower_amount: int = 0
plane_amount: int = 0
hole_amount: int = 0
timemachine_amount: int = 0
glass_amount: int = 0
js_amount: int = 0
building_amount: int = 0
price_sponsor: int = 10
price_seed: int = 80
price_basket: int = 340
price_tree: int = 1500
price_garden: int = 6200
price_town: int = 14000
price_country: int = 89000
price_planet: int = 254000
price_wizardtower: int = 792000
price_plane: int = 1850000
price_hole: int = 4640000
price_timemachine: int = 27000000
price_glass: int = 315000000
price_js: int = 1710000000
value_sponsor: int = 1
value_seed: int = 3
value_basket: int = 6
value_tree: int = 15
value_garden: int = 30
value_town: int = 50
value_country: int = 80
value_planet: int = 150
value_wizardtower: int = 270
value_plane: int = 400
value_hole: int = 750
value_timemachine: int = 980
value_glass: int = 1200
value_js: int = 1600
button_clicked_amount_2: int = 0
button_clicked_amount_3: int = 0
button_clicked_amount_4: int = 0
button_clicked_amount_5: int = 0
button_clicked_amount_6: int = 0
button_clicked_amount_7: int = 0
button_clicked_amount_8: int = 0
button_clicked_amount_9: int = 0
button_clicked_amount_10: int = 0
button_clicked_amount_11: int = 0
button_clicked_amount_12: int = 0
button_clicked_amount_13: int = 0
button_clicked_amount_14: int = 0
button_clicked_amount_15: int = 0
click_time: int = 0
upgrade_price: int = 200000
upgrade_button_clicked_time: int = 0
level_progress_now: int = 1
left_label = "Level " + str(level_progress_now)
right_label = "Level " + str(level_progress_now + 1)
difficulty_add_multiply: float = 1.2
information: str = "Welcome to Apple Clicker©! Author/Copyright: Xuange_Aha" # 初始信息
def main_main_operation_logic_thread(): # 主要运算逻辑线程
global apple_amount
global apple_amount_total
global building_amount
whee = 0
while whee == 0:
global auto_add_per_second
auto_add_per_second = int(((sponsor_amount * value_sponsor) + \
(seed_amount * value_seed) + \
(basket_amount * value_basket) + \
(tree_amount * value_tree) + \
(garden_amount * value_garden) + \
(town_amount * value_town) + \
(country_amount * value_country) + \
(planet_amount * value_planet) + \
(wizardtower_amount * value_wizardtower) + \
(plane_amount * value_plane) + \
(hole_amount * value_hole) + \
(timemachine_amount * value_timemachine) + \
(glass_amount * value_glass) + \
(js_amount * value_js)) * pow(1.02, upgrade_button_clicked_time + 1))
apple_amount += auto_add_per_second
apple_amount_total += auto_add_per_second
global add_per_click
add_per_click = int((sponsor_amount * 1) + \
(seed_amount * 1.5) + \
(basket_amount * 2) + \
(tree_amount * 2.5) + \
(garden_amount * 3) + \
(town_amount * 3.5) + \
(country_amount * 4) + \
(planet_amount * 4.5) + \
(wizardtower_amount * 5) + \
(plane_amount * 5.5) + \
(hole_amount * 6) + \
(timemachine_amount * 6.5) + \
(glass_amount * 7) + \
(js_amount * 7.5) + 1)
building_amount = sponsor_amount + seed_amount + basket_amount + tree_amount + garden_amount + \
town_amount + country_amount + planet_amount + wizardtower_amount + \
plane_amount + hole_amount + timemachine_amount + glass_amount + js_amount
global upgrade_price
upgrade_price = int(200000 * pow(1.2, upgrade_button_clicked_time))
global level_progress_now
if apple_amount_total < 12000:
level_progress_now = 1
elif 12000 < apple_amount_total < 60000:
level_progress_now = 2
elif 60000 < apple_amount_total < 200000:
level_progress_now = 3
elif 200000 < apple_amount_total < 1000000:
level_progress_now = 4
elif 1000000 < apple_amount_total < 5500000:
level_progress_now = 5
elif 5500000 < apple_amount_total < 18000000:
level_progress_now = 6
elif 18000000 < apple_amount_total < 60000000:
level_progress_now = 7
elif 60000000 < apple_amount_total < 200000000:
level_progress_now = 8
elif 200000000 < apple_amount_total < 1000000000:
level_progress_now = 9
else:
level_progress_now = 10
time.sleep(1)
def click_button_clicked(): # 苹果按钮点击运算
global apple_amount
global apple_amount_total
global click_time
apple_amount += add_per_click
apple_amount_total += add_per_click
click_time += 1
def sponsor_button_clicked(): # 建筑购买运算
global apple_amount
global price_sponsor
global sponsor_amount
global information
global button_clicked_amount_2
if (apple_amount - price_sponsor) < 0:
information = "Not enough apples. You must have at least " + str(price_sponsor) + " apples to buy Cursor."
else:
information = "You have just bought 1 * Cursor"
apple_amount -= price_sponsor
button_clicked_amount_2 += 1
price_sponsor += button_clicked_amount_2
sponsor_amount += 1
def seed_button_clicked():
global apple_amount
global price_seed
global seed_amount
global information
global button_clicked_amount_3
if (apple_amount - price_seed) < 0:
information = "Not enough apples. You must have at least " + str(price_seed) + " apples to buy Seed."
else:
information = "You have just bought 1 * Seed"
apple_amount -= price_seed
button_clicked_amount_3 += 1
price_seed += button_clicked_amount_3 + 1
seed_amount += 1
def basket_button_clicked():
global apple_amount
global price_basket
global basket_amount
global information
global button_clicked_amount_4
if (apple_amount - price_basket) < 0:
information = "Not enough apples. You must have at least " + str(price_basket) + " apples to buy Basket."
else:
information = "You have just bought 1 * Basket"
apple_amount -= price_basket
button_clicked_amount_4 += 1
price_basket += button_clicked_amount_4 + 2
basket_amount += 1
def tree_button_clicked():
global apple_amount
global price_tree
global tree_amount
global information
global button_clicked_amount_5
if (apple_amount - price_tree) < 0:
information = "Not enough apples. You must have at least " + str(price_tree) + " apples to buy Apple Tree."
else:
information = "You have just bought 1 * Apple Tree"
apple_amount -= price_tree
button_clicked_amount_5 += 1
price_tree += button_clicked_amount_5 + 3
tree_amount += 1
def garden_button_clicked():
global apple_amount
global price_garden
global garden_amount
global information
global button_clicked_amount_6
if (apple_amount - price_garden) < 0:
information = "Not enough apples. You must have at least " + str(
price_garden) + " apples to buy Harvest Garden."
else:
information = "You have just bought 1 * Harvest Garden"
apple_amount -= price_garden
button_clicked_amount_6 += 1
price_garden += button_clicked_amount_6 + 4
garden_amount += 1
def town_button_clicked():
global apple_amount
global price_town
global town_amount
global information
global button_clicked_amount_7
if (apple_amount - price_town) < 0:
information = "Not enough apples. You must have at least " + str(price_town) + " apples to buy Fruit Town."
else:
information = "You have just bought 1 * Fruit Town"
apple_amount -= price_town
button_clicked_amount_7 += 1
price_town += button_clicked_amount_7 + 5
town_amount += 1
def country_button_clicked():
global apple_amount
global price_country
global country_amount
global information
global button_clicked_amount_8
if (apple_amount - price_country) < 0:
information = "Not enough apples. You must have at least " + str(
price_country) + " apples to buy Apple Kingdom."
else:
information = "You have just bought 1 * Apple Kingdom"
apple_amount -= price_country
button_clicked_amount_8 += 1
price_country += button_clicked_amount_8 + 6
country_amount += 1
def planet_button_clicked():
global apple_amount
global price_planet
global planet_amount
global information
global button_clicked_amount_9
if (apple_amount - price_planet) < 0:
information = "Not enough apples. You must have at least " + str(price_planet) + " apples to buy Juicy Planet."
else:
information = "You have just bought 1 * Juicy Planet"
apple_amount -= price_planet
button_clicked_amount_9 += 1
price_planet += button_clicked_amount_9 + 7
planet_amount += 1
def wizardtower_button_clicked():
global apple_amount
global price_wizardtower
global wizardtower_amount
global information
global button_clicked_amount_10
if (apple_amount - price_wizardtower) < 0:
information = "Not enough apples. You must have at least " + str(
price_wizardtower) + " apples to buy Wizardtower."
else:
information = "You have just bought 1 * Wizardtower"
apple_amount -= price_wizardtower
button_clicked_amount_10 += 1
price_wizardtower += button_clicked_amount_10 + 8
wizardtower_amount += 1
def plane_button_clicked():
global apple_amount
global price_plane
global plane_amount
global information
global button_clicked_amount_11
if (apple_amount - price_plane) < 0:
information = "Not enough apples. You must have at least " + str(price_plane) + " apples to buy Spacecraft."
else:
information = "You have just bought 1 * Spacecraft"
apple_amount -= price_plane
button_clicked_amount_11 += 1
price_plane += button_clicked_amount_11 + 9
plane_amount += 1
def hole_button_clicked():
global apple_amount
global price_hole
global hole_amount
global information
global button_clicked_amount_12
if (apple_amount - price_hole) < 0:
information = "Not enough apples. You must have at least " + str(price_hole) + " apples to buy Wormhole."
else:
information = "You have just bought 1 * Wormhole"
apple_amount -= price_hole
button_clicked_amount_12 += 1
price_hole += button_clicked_amount_12 + 10
hole_amount += 1
def timemachine_button_clicked():
global apple_amount
global price_timemachine
global timemachine_amount
global information
global button_clicked_amount_13
if (apple_amount - price_timemachine) < 0:
information = "Not enough apples. You must have at least " + str(
price_timemachine) + " apples to buy Timemachine."
else:
information = "You have just bought 1 * Timemachine"
apple_amount -= price_timemachine
button_clicked_amount_13 += 1
price_timemachine += button_clicked_amount_13 + 11
timemachine_amount += 1
def glass_button_clicked():
global apple_amount
global price_glass
global glass_amount
global information
global button_clicked_amount_14
if (apple_amount - price_glass) < 0:
information = "Not enough apples. You must have at least " + str(
price_glass) + " apples to buy Antimatter Condenser."
else:
information = "You have just bought 1 * Antimatter Condenser"
apple_amount -= price_glass
button_clicked_amount_14 += 1
price_glass += button_clicked_amount_14 + 12
glass_amount += 1
def js_button_clicked():
global apple_amount
global price_js
global js_amount
global information
global button_clicked_amount_15
if (apple_amount - price_js) < 0:
information = "Not enough apples. You must have at least " + str(
price_js) + " apples to buy JavaScript Control Table."
else:
information = "You have just bought 1 * JavaScript Control Table"
apple_amount -= price_js
button_clicked_amount_15 += 1
price_js += button_clicked_amount_15 + 13
js_amount += 1
def apple_amount_entry_update(): # 左侧信息栏显示运算
global apple_amount
apple_amount_entry.delete(0, "end")
apple_amount_entry.insert(0, str(apple_amount))
apple_amount_entry.after(1, apple_amount_entry_update)
def apple_per_click_entry_update():
global add_per_click
apple_per_click_entry.delete(0, "end")
apple_per_click_entry.insert(0, ("+ " + str(add_per_click) + " / click"))
apple_per_click_entry.after(1, apple_per_click_entry_update)
def apple_per_second_entry_update():
global auto_add_per_second
apple_per_second_entry.delete(0, "end")
apple_per_second_entry.insert(0, ("+ " + str(auto_add_per_second) + " / s"))
apple_per_second_entry.after(1, apple_per_second_entry_update)
def entry_information_number_23_upgrade(): # 信息网格显示运算
global sponsor_amount
entry_information_number_23.delete(0, "end")
entry_information_number_23.insert(0, str(sponsor_amount))
entry_information_number_23.after(100, entry_information_number_23_upgrade)
def entry_information_number_33_upgrade():
global seed_amount
entry_information_number_33.delete(0, "end")
entry_information_number_33.insert(0, str(seed_amount))
entry_information_number_33.after(100, entry_information_number_33_upgrade)
def entry_information_number_43_upgrade():
global basket_amount
entry_information_number_43.delete(0, "end")
entry_information_number_43.insert(0, str(basket_amount))
entry_information_number_43.after(100, entry_information_number_43_upgrade)
def entry_information_number_53_upgrade():
global tree_amount
entry_information_number_53.delete(0, "end")
entry_information_number_53.insert(0, str(tree_amount))
entry_information_number_53.after(100, entry_information_number_53_upgrade)
def entry_information_number_63_upgrade():
global garden_amount
entry_information_number_63.delete(0, "end")
entry_information_number_63.insert(0, str(garden_amount))
entry_information_number_63.after(100, entry_information_number_63_upgrade)
def entry_information_number_73_upgrade():
global town_amount
entry_information_number_73.delete(0, "end")
entry_information_number_73.insert(0, str(town_amount))
entry_information_number_73.after(100, entry_information_number_73_upgrade)
def entry_information_number_83_upgrade():
global country_amount
entry_information_number_83.delete(0, "end")
entry_information_number_83.insert(0, str(country_amount))
entry_information_number_83.after(100, entry_information_number_83_upgrade)
def entry_information_number_93_upgrade():
global planet_amount
entry_information_number_93.delete(0, "end")
entry_information_number_93.insert(0, str(planet_amount))
entry_information_number_93.after(100, entry_information_number_93_upgrade)
def entry_information_number_103_upgrade():
global wizardtower_amount
entry_information_number_103.delete(0, "end")
entry_information_number_103.insert(0, str(wizardtower_amount))
entry_information_number_103.after(100, entry_information_number_103_upgrade)
def entry_information_number_113_upgrade():
global plane_amount
entry_information_number_113.delete(0, "end")
entry_information_number_113.insert(0, str(plane_amount))
entry_information_number_113.after(100, entry_information_number_113_upgrade)
def entry_information_number_123_upgrade():
global hole_amount
entry_information_number_123.delete(0, "end")
entry_information_number_123.insert(0, str(hole_amount))
entry_information_number_123.after(100, entry_information_number_123_upgrade)
def entry_information_number_133_upgrade():
global timemachine_amount
entry_information_number_133.delete(0, "end")
entry_information_number_133.insert(0, str(timemachine_amount))
entry_information_number_133.after(100, entry_information_number_133_upgrade)
def entry_information_number_143_upgrade():
global glass_amount
entry_information_number_143.delete(0, "end")
entry_information_number_143.insert(0, str(glass_amount))
entry_information_number_143.after(100, entry_information_number_143_upgrade)
def entry_information_number_153_upgrade():
global js_amount
entry_information_number_153.delete(0, "end")
entry_information_number_153.insert(0, str(js_amount))
entry_information_number_153.after(100, entry_information_number_153_upgrade)
def entry_information_number_24_upgrade():
global price_sponsor
entry_information_number_24.delete(0, "end")
entry_information_number_24.insert(0, str(price_sponsor))
entry_information_number_24.after(100, entry_information_number_24_upgrade)
def entry_information_number_34_upgrade():
global price_seed
entry_information_number_34.delete(0, "end")
entry_information_number_34.insert(0, str(price_seed))
entry_information_number_34.after(100, entry_information_number_34_upgrade)
def entry_information_number_44_upgrade():
global price_basket
entry_information_number_44.delete(0, "end")
entry_information_number_44.insert(0, str(price_basket))
entry_information_number_44.after(100, entry_information_number_44_upgrade)
def entry_information_number_54_upgrade():
global price_tree
entry_information_number_54.delete(0, "end")
entry_information_number_54.insert(0, str(price_tree))
entry_information_number_54.after(100, entry_information_number_54_upgrade)
def entry_information_number_64_upgrade():
global price_garden
entry_information_number_64.delete(0, "end")
entry_information_number_64.insert(0, str(price_garden))
entry_information_number_64.after(100, entry_information_number_64_upgrade)
def entry_information_number_74_upgrade():
global price_town
entry_information_number_74.delete(0, "end")
entry_information_number_74.insert(0, str(price_town))
entry_information_number_74.after(100, entry_information_number_74_upgrade)
def entry_information_number_84_upgrade():
global price_country
entry_information_number_84.delete(0, "end")
entry_information_number_84.insert(0, str(price_country))
entry_information_number_84.after(100, entry_information_number_84_upgrade)
def entry_information_number_94_upgrade():
global price_planet
entry_information_number_94.delete(0, "end")
entry_information_number_94.insert(0, str(price_planet))
entry_information_number_94.after(100, entry_information_number_94_upgrade)
def entry_information_number_104_upgrade():
global price_wizardtower
entry_information_number_104.delete(0, "end")
entry_information_number_104.insert(0, str(price_wizardtower))
entry_information_number_104.after(100, entry_information_number_104_upgrade)
def entry_information_number_114_upgrade():
global price_plane
entry_information_number_114.delete(0, "end")
entry_information_number_114.insert(0, str(price_plane))
entry_information_number_114.after(100, entry_information_number_114_upgrade)
def entry_information_number_124_upgrade():
global price_hole
entry_information_number_124.delete(0, "end")
entry_information_number_124.insert(0, str(price_hole))
entry_information_number_124.after(100, entry_information_number_124_upgrade)
def entry_information_number_134_upgrade():
global price_timemachine
entry_information_number_134.delete(0, "end")
entry_information_number_134.insert(0, str(price_timemachine))
entry_information_number_134.after(100, entry_information_number_134_upgrade)
def entry_information_number_144_upgrade():
global price_glass
entry_information_number_144.delete(0, "end")
entry_information_number_144.insert(0, str(price_glass))
entry_information_number_144.after(100, entry_information_number_144_upgrade)
def entry_information_number_154_upgrade():
global price_js
entry_information_number_154.delete(0, "end")
entry_information_number_154.insert(0, str(price_js))
entry_information_number_154.after(100, entry_information_number_154_upgrade)
def entry_information_number_25_upgrade():
global value_sponsor
entry_information_number_25.delete(0, "end")
entry_information_number_25.insert(0, ("+" + str(value_sponsor * sponsor_amount)) + " / s")
entry_information_number_25.after(100, entry_information_number_25_upgrade)
def entry_information_number_35_upgrade():
global value_seed
entry_information_number_35.delete(0, "end")
entry_information_number_35.insert(0, ("+" + str(value_seed * seed_amount)) + " / s")
entry_information_number_35.after(100, entry_information_number_35_upgrade)
def entry_information_number_45_upgrade():
global value_basket
entry_information_number_45.delete(0, "end")
entry_information_number_45.insert(0, ("+" + str(value_basket * basket_amount)) + " / s")
entry_information_number_45.after(100, entry_information_number_45_upgrade)
def entry_information_number_55_upgrade():
global value_tree
entry_information_number_55.delete(0, "end")
entry_information_number_55.insert(0, ("+" + str(value_tree * tree_amount)) + " / s")
entry_information_number_55.after(100, entry_information_number_55_upgrade)
def entry_information_number_65_upgrade():
global value_garden
entry_information_number_65.delete(0, "end")
entry_information_number_65.insert(0, ("+" + str(value_garden * garden_amount)) + " / s")
entry_information_number_65.after(100, entry_information_number_65_upgrade)
def entry_information_number_75_upgrade():
global value_town
entry_information_number_75.delete(0, "end")
entry_information_number_75.insert(0, ("+" + str(value_town * town_amount)) + " / s")
entry_information_number_75.after(100, entry_information_number_75_upgrade)
def entry_information_number_85_upgrade():
global value_country
entry_information_number_85.delete(0, "end")
entry_information_number_85.insert(0, ("+" + str(value_country * country_amount)) + " / s")
entry_information_number_85.after(100, entry_information_number_85_upgrade)
def entry_information_number_95_upgrade():
global value_planet
entry_information_number_95.delete(0, "end")
entry_information_number_95.insert(0, ("+" + str(value_planet * planet_amount)) + " / s")
entry_information_number_95.after(100, entry_information_number_95_upgrade)
def entry_information_number_105_upgrade():
global value_wizardtower
entry_information_number_105.delete(0, "end")
entry_information_number_105.insert(0, ("+" + str(value_wizardtower * wizardtower_amount)) + " / s")
entry_information_number_105.after(100, entry_information_number_105_upgrade)
def entry_information_number_115_upgrade():
global value_plane
entry_information_number_115.delete(0, "end")
entry_information_number_115.insert(0, ("+" + str(value_plane * plane_amount)) + " / s")
entry_information_number_115.after(100, entry_information_number_115_upgrade)
def entry_information_number_125_upgrade():
global value_hole
entry_information_number_125.delete(0, "end")
entry_information_number_125.insert(0, ("+" + str(value_hole * hole_amount)) + " / s")
entry_information_number_125.after(100, entry_information_number_125_upgrade)
def entry_information_number_135_upgrade():
global value_timemachine
entry_information_number_135.delete(0, "end")
entry_information_number_135.insert(0, ("+" + str(value_timemachine * timemachine_amount)) + " / s")
entry_information_number_135.after(100, entry_information_number_135_upgrade)
def entry_information_number_145_upgrade():
global value_glass
entry_information_number_145.delete(0, "end")
entry_information_number_145.insert(0, ("+" + str(value_glass * glass_amount)) + " / s")
entry_information_number_145.after(100, entry_information_number_145_upgrade)
def entry_information_number_155_upgrade():
global value_js
entry_information_number_155.delete(0, "end")
entry_information_number_155.insert(0, ("+" + str(value_js * js_amount)) + " / s")
entry_information_number_155.after(100, entry_information_number_155_upgrade)
def entry_information_information_upgrade():
entry_information_information.delete(0, "end")
entry_information_information.insert(0, information)
entry_information_information.after(100, entry_information_information_upgrade)
def window_download(): # 存档下载窗口
rootdownload = tk.Tk()
rootdownload.title("Download Save")
rootdownload.resizable(0, 0)
encode_string: str = str(apple_amount) + "|" + str(apple_amount_total) + "|" + str(sponsor_amount) + "|" + str(
seed_amount) + "|" + str(basket_amount) + "|" + str(tree_amount) + "|" + str(garden_amount) + "|" + str(
town_amount) + "|" + str(country_amount) + "|" + str(planet_amount) + "|" + str(wizardtower_amount) + "|" + str(
plane_amount) + "|" + str(hole_amount) + "|" + str(timemachine_amount) + "|" + str(glass_amount) + "|" + str(
js_amount) + "|" + str(click_time)
str_encoded = cryptocode.encrypt(encode_string, "Minecraft is love, minecraft is life, minecraft is everything! ")
save_download_label = tk.Label(rootdownload, text="Please store this string properly and safely. "
"Click \"Upload\" Button and enter the string to continue next time! ")
save_download_label.pack()
save_download_entry = tk.Entry(rootdownload, width=150, justify='center')
save_download_entry.insert(0, str_encoded)
save_download_entry.pack()
def download_close():
rootdownload.destroy()
save_download_button = tk.Button(rootdownload, width=10, text="Close", command=download_close)
save_download_button.pack()
rootdownload.mainloop()
def window_upload(): # 存档上传窗口
rootupload = tk.Tk()
rootupload.title("Upload Save")
rootupload.resizable(0, 0)
save_upload_label = tk.Label(rootupload, text="Please enter the string you saved to continue! ")
save_upload_label.pack()
save_upload_entry = tk.Entry(rootupload, width=150, justify='center')
save_upload_entry.pack()
def upload():
global apple_amount
global apple_amount_total
global sponsor_amount
global seed_amount
global basket_amount
global tree_amount
global garden_amount
global town_amount
global country_amount
global planet_amount
global wizardtower_amount
global plane_amount
global hole_amount
global timemachine_amount
global glass_amount
global js_amount
global click_time
global button_clicked_amount_2
global button_clicked_amount_3
global button_clicked_amount_4
global button_clicked_amount_5
global button_clicked_amount_6
global button_clicked_amount_7
global button_clicked_amount_8
global button_clicked_amount_9
global button_clicked_amount_10
global button_clicked_amount_11
global button_clicked_amount_12
global button_clicked_amount_13
global button_clicked_amount_14
global button_clicked_amount_15
global price_sponsor
global price_seed
global price_basket
global price_tree
global price_garden
global price_town
global price_country
global price_planet
global price_wizardtower
global price_plane
global price_hole
global price_timemachine
global price_glass
global price_js
get_string = save_upload_entry.get()
str_decoded = cryptocode.decrypt(get_string, "Minecraft is love, minecraft is life, minecraft is everything! ")
tuple_ud = str_decoded.split("|")
apple_amount = int(tuple_ud[0])
apple_amount_total = int(tuple_ud[1])
sponsor_amount = int(tuple_ud[2])
seed_amount = int(tuple_ud[3])
basket_amount = int(tuple_ud[4])
tree_amount = int(tuple_ud[5])
garden_amount = int(tuple_ud[6])
town_amount = int(tuple_ud[7])
country_amount = int(tuple_ud[8])
planet_amount = int(tuple_ud[9])
wizardtower_amount = int(tuple_ud[10])
plane_amount = int(tuple_ud[11])
hole_amount = int(tuple_ud[12])
timemachine_amount = int(tuple_ud[13])
glass_amount = int(tuple_ud[14])
js_amount = int(tuple_ud[15])
click_time = int(tuple_ud[16])
button_clicked_amount_2 += sponsor_amount
price_sponsor += button_clicked_amount_2
button_clicked_amount_3 += seed_amount
price_seed += button_clicked_amount_3
button_clicked_amount_4 += basket_amount
price_basket += button_clicked_amount_4
button_clicked_amount_5 += tree_amount
price_tree += button_clicked_amount_5
button_clicked_amount_6 += garden_amount
price_garden += button_clicked_amount_6
button_clicked_amount_7 += town_amount
price_town += button_clicked_amount_7
button_clicked_amount_8 += country_amount
price_country += button_clicked_amount_8
button_clicked_amount_9 += planet_amount
price_planet += button_clicked_amount_9
button_clicked_amount_10 += wizardtower_amount
price_wizardtower += button_clicked_amount_10
button_clicked_amount_11 += plane_amount
price_plane += button_clicked_amount_11
button_clicked_amount_12 += hole_amount
price_hole += button_clicked_amount_12
button_clicked_amount_13 += timemachine_amount
price_timemachine += button_clicked_amount_13
button_clicked_amount_14 += glass_amount
price_glass += button_clicked_amount_14
button_clicked_amount_15 += js_amount
price_js += button_clicked_amount_15
save_upload_button = tk.Button(rootupload, width=10, text="Upload", command=upload)
save_upload_button.pack()
rootupload.mainloop()
def window_about(): # 关于窗口
rootabout = tk.Toplevel()
rootabout.title("About: Apple Clicker©")
rootabout.resizable(0, 0)
frame_icon = tk.Frame(rootabout,padx=50)
frame_icon.grid(row=0,column=0)
icon_img = tk.PhotoImage(file='./assets/app.gif')
icon_label = tk.Label(frame_icon, image=icon_img)
icon_label.pack(anchor='center', pady=40)
icon_label_title = tk.Label(frame_icon, text=("Apple Clicker© " + ver), font=("Arial", 17))
icon_label_title.pack(anchor='center')
icon_label_title = tk.Label(frame_icon, text="Author/Copyright: Xuange_Aha", font=("Arial", 13))
icon_label_title.pack(anchor='center')
button_frame = tk.Frame(frame_icon)
button_frame.pack(anchor='center')
def log_clicked():
global label
label = "Update log"
file_open = open("log/log.txt", "r", encoding='utf-8')
file_log = file_open.read()
file_open.close()
text_about.delete(1.0, tk.END)
text_about.insert("insert", file_log)
def credit_clicked():
global label
label = "Credits"
file_open = open("log/credits.txt", "r", encoding='utf-8')
file_log = file_open.read()
file_open.close()
text_about.delete(1.0, tk.END)
text_about.insert("insert", file_log)
def module_clicked():
global label
label = "Module list"
file_open = open("log/module.txt", "r", encoding='utf-8')
file_log = file_open.read()
file_open.close()
text_about.delete(1.0, tk.END)
text_about.insert("insert", file_log)
button_log = tk.Button(button_frame, text="Update log",command=log_clicked)
button_log.grid(row=1, column=1)
button_credit = tk.Button(button_frame, text="Credits",command=credit_clicked)
button_credit.grid(row=1, column=2)
button_module = tk.Button(button_frame, text="Modules",command=module_clicked)
button_module.grid(row=1, column=3)
def text_label_update():
global label
text_label['text'] = label
text_label.after(100, text_label_update)
frame_text = tk.Frame(rootabout,padx=15,pady=15)
frame_text.grid(row=0,column=1)
text_label = tk.Label(frame_text)
text_label.pack()
text_label.after(100,text_label_update)
text_about = tk.Text(frame_text,width=60)
text_about.pack()
label = "Update log"
file_open = open("log/log.txt", "r", encoding='utf-8')
file_log = file_open.read()
file_open.close()
text_about.delete(1.0, tk.END)
text_about.insert("insert", file_log)
rootabout.mainloop()
def statistics_text_upgrade(): # 统计信息显示运算
statistics_text.delete(1.0, tk.END)
statistics_text.insert("insert", ("Apple amount now:" + str(apple_amount) +
"\nApple amount total:" + str(apple_amount_total) +
"\nBuildings amount total:" + str(building_amount) +
"\nClick time:" + str(click_time) +
"\nTime:" + time.asctime(time.localtime(time.time()))))
statistics_text.after(100, statistics_text_upgrade)
def upgrade_button_clicked(): # 升级运算
global apple_amount
global information
global upgrade_button_clicked_time
if (apple_amount - upgrade_price) < 0:
information = "Not enough apples. You must have at least " + str(int(upgrade_price)) + " apples to upgrade."
else:
apple_amount -= upgrade_price
upgrade_button_clicked_time += 1
information = "You have just upgraded to Level " + str(upgrade_button_clicked_time + 1) + "! "
def statistics_button_entry_update():
statistics_button_entry.delete(0, "end")
statistics_button_entry.insert(0, "Level " + str(upgrade_button_clicked_time + 1) + " to Level " + str(
upgrade_button_clicked_time + 2))
statistics_button_entry.after(100, statistics_button_entry_update)
def statistics_button_entry_price_update():
statistics_button_entry_price.delete(0, "end")
statistics_button_entry_price.insert(0, "Price: " + str(int(upgrade_price)))
statistics_button_entry_price.after(100, statistics_button_entry_price_update)
def level_progress_bar_update(): # 等级进度条运算
if level_progress_now == 1:
level_progress_bar['maximum'] = 12000
level_progress_bar['value'] = apple_amount_total
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 2:
level_progress_bar['maximum'] = 48000
level_progress_bar['value'] = apple_amount_total - 12000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 3:
level_progress_bar['maximum'] = 140000
level_progress_bar['value'] = apple_amount_total - 60000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 4:
level_progress_bar['maximum'] = 800000
level_progress_bar['value'] = apple_amount_total - 200000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 5:
level_progress_bar['maximum'] = 4500000
level_progress_bar['value'] = apple_amount_total - 1000000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 6:
level_progress_bar['maximum'] = 12500000
level_progress_bar['value'] = apple_amount_total - 5500000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 7:
level_progress_bar['maximum'] = 42000000
level_progress_bar['value'] = apple_amount_total - 18000000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 8:
level_progress_bar['maximum'] = 140000000
level_progress_bar['value'] = apple_amount_total - 60000000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 9:
level_progress_bar['maximum'] = 800000000
level_progress_bar['value'] = apple_amount_total - 200000000
level_progress_bar.after(100, level_progress_bar_update)
elif level_progress_now == 10:
level_progress_bar['maximum'] = 100000000000
level_progress_bar['value'] = apple_amount_total - 1000000000
level_progress_bar.after(100, level_progress_bar_update)
else:
pass
def level_progress_label_left_update():
global left_label
level_progress_label_left.delete(0, "end")
level_progress_label_left.insert(0, "Level " + str(level_progress_now))
level_progress_label_left.after(100, level_progress_label_left_update)
def level_progress_label_right_update():
global right_label
level_progress_label_right.delete(0, "end")
level_progress_label_right.insert(0, "Level " + str(level_progress_now + 1))
level_progress_label_right.after(100, level_progress_label_right_update)
def root_close(): # 窗口关闭
root.destroy()
sys.exit()
root = tk.Tk() # 主窗口
root.title("Apple Clicker© " + ver)
root.iconphoto(True, tk.PhotoImage(file='./assets/app.png'))
root.resizable(0, 0)
style = Style(theme='apple7')
auto_amount_add_per_second_thread = threading.Thread(target=main_main_operation_logic_thread) # 主要运算逻辑线程启动
auto_amount_add_per_second_thread.start()
frame_button = tk.Frame(root)
frame_button.grid(row=1, column=2)
button_sponsor = tk.Button(frame_button, text="Buy Cursor", command=sponsor_button_clicked) # 建筑购买按钮
button_sponsor.grid(row=2, column=1)
button_seed = tk.Button(frame_button, text="Buy Seed", command=seed_button_clicked)
button_seed.grid(row=3, column=1)
button_basket = tk.Button(frame_button, text="Buy Basket", command=basket_button_clicked)
button_basket.grid(row=4, column=1)
button_tree = tk.Button(frame_button, text="Buy Apple Tree", command=tree_button_clicked)
button_tree.grid(row=5, column=1)
button_garden = tk.Button(frame_button, text="Buy Harvest Garden", command=garden_button_clicked)
button_garden.grid(row=6, column=1)
button_town = tk.Button(frame_button, text="Buy Fruit Town", command=town_button_clicked)
button_town.grid(row=7, column=1)
button_country = tk.Button(frame_button, text="Buy Apple Kingdom", command=country_button_clicked)
button_country.grid(row=8, column=1)
button_planet = tk.Button(frame_button, text="Buy Juicy Planet", command=planet_button_clicked)
button_planet.grid(row=9, column=1)
button_wizardtower = tk.Button(frame_button, text="Buy Wizardtower", command=wizardtower_button_clicked)
button_wizardtower.grid(row=10, column=1)
button_plane = tk.Button(frame_button, text="Buy Spacecraft", command=plane_button_clicked)
button_plane.grid(row=11, column=1)
button_hole = tk.Button(frame_button, text="Buy Wormhole", command=hole_button_clicked)
button_hole.grid(row=12, column=1)
button_timemachine = tk.Button(frame_button, text="Buy Timemachine", command=timemachine_button_clicked)
button_timemachine.grid(row=13, column=1)
button_glass = tk.Button(frame_button, text="Buy Antimatter Condenser", command=glass_button_clicked)
button_glass.grid(row=14, column=1)
button_js = tk.Button(frame_button, text="Buy JavaScript Control Table", command=js_button_clicked)
button_js.grid(row=15, column=1)
label_2 = tk.Label(frame_button, text="Let these cute cursors help you click and click! ") # 建筑简介
label_2.grid(row=2, column=2)
label_3 = tk.Label(frame_button, text="These apple seeds of quality can give you 3 apples per second! ")
label_3.grid(row=3, column=2)
label_4 = tk.Label(frame_button, text="Fantastic choice for Sunday family picnic! ")
label_4.grid(row=4, column=2)
label_5 = tk.Label(frame_button, text="Apple trees which harvest all year round! ")
label_5.grid(row=5, column=2)
label_6 = tk.Label(frame_button, text="Now grow apples in the backyard of your house! ")
label_6.grid(row=6, column=2)
label_7 = tk.Label(frame_button, text="A town where everyone grow and eat apples in it! ")
label_7.grid(row=7, column=2)
label_8 = tk.Label(frame_button, text="The streets and alleys are filled with a refreshing fragrance! ")
label_8.grid(row=8, column=2)
label_9 = tk.Label(frame_button, text="People finally discovered organic matter millions of light-years away! ")
label_9.grid(row=9, column=2)
label_10 = tk.Label(frame_button, text="Deep into the unverse to get apples on your spacecraft! ")
label_10.grid(row=10, column=2)
label_11 = tk.Label(frame_button, text="Summon a large amount of apples from wizardtowers! ")
label_11.grid(row=11, column=2)
label_12 = tk.Label(frame_button, text="Access to a lot of apples in a parallel universe! ")
label_12.grid(row=12, column=2)
label_13 = tk.Label(frame_button, text="Go back to the past or future to look for more apples! ")
label_13.grid(row=13, column=2)
label_14 = tk.Label(frame_button, text="Change the antimatter in the universe into apples! ")
label_14.grid(row=14, column=2)
label_15 = tk.Label(frame_button, text="Get endless amount of apples by JavaScript! ")
label_15.grid(row=15, column=2)
frame_left = tk.Frame(root, padx=10)
frame_left.grid(row=1, column=1, rowspan=3)
apple_amount_entry = tk.Entry(frame_left, # 左侧信息栏
justify='center',
font=("", "14"),
width=16)
apple_amount_entry.pack()
apple_amount_entry.after(10, apple_amount_entry_update)
apple_per_click_entry = tk.Entry(frame_left, width=23)
apple_per_click_entry.pack()
apple_per_click_entry.after(100, apple_per_click_entry_update)
apple_per_second_entry = tk.Entry(frame_left, width=23)
apple_per_second_entry.pack()
apple_per_second_entry.after(100, apple_per_second_entry_update)
apple_img = tk.PhotoImage(file="./assets/app.png")
button_click = tk.Button(frame_left, # 苹果点击按钮
command=click_button_clicked,
image=apple_img,
width=160, height=160)
button_click.pack()
information_label_column_1 = tk.Label(frame_button, text="Buildings") # 顶部
information_label_column_1.grid(row=1, column=1, pady=2)
information_label_column_2 = tk.Label(frame_button, text="Introductions")
information_label_column_2.grid(row=1, column=2, pady=2)
information_label_column_3 = tk.Label(frame_button, text="Amounts")
information_label_column_3.grid(row=1, column=3, pady=2)
information_label_column_4 = tk.Label(frame_button, text="Prices")
information_label_column_4.grid(row=1, column=4, pady=2)
information_label_column_5 = tk.Label(frame_button, text="Speeds")
information_label_column_5.grid(row=1, column=5, pady=2)
information_label_column_6 = tk.Label(frame_button, text="Achievements")
information_label_column_6.grid(row=1, column=6, pady=2)
entry_information_number_23 = tk.Entry(frame_button, width=5) # 信息网格
entry_information_number_23.grid(row=2, column=3)
entry_information_number_23.after(100, entry_information_number_23_upgrade)
entry_information_number_33 = tk.Entry(frame_button, width=5)
entry_information_number_33.grid(row=3, column=3)
entry_information_number_33.after(100, entry_information_number_33_upgrade)
entry_information_number_43 = tk.Entry(frame_button, width=5)
entry_information_number_43.grid(row=4, column=3)
entry_information_number_43.after(100, entry_information_number_43_upgrade)
entry_information_number_53 = tk.Entry(frame_button, width=5)
entry_information_number_53.grid(row=5, column=3)
entry_information_number_53.after(100, entry_information_number_53_upgrade)
entry_information_number_63 = tk.Entry(frame_button, width=5)
entry_information_number_63.grid(row=6, column=3)
entry_information_number_63.after(100, entry_information_number_63_upgrade)
entry_information_number_73 = tk.Entry(frame_button, width=5)
entry_information_number_73.grid(row=7, column=3)
entry_information_number_73.after(100, entry_information_number_73_upgrade)
entry_information_number_83 = tk.Entry(frame_button, width=5)
entry_information_number_83.grid(row=8, column=3)
entry_information_number_83.after(100, entry_information_number_83_upgrade)
entry_information_number_93 = tk.Entry(frame_button, width=5)
entry_information_number_93.grid(row=9, column=3)
entry_information_number_93.after(100, entry_information_number_93_upgrade)
entry_information_number_103 = tk.Entry(frame_button, width=5)
entry_information_number_103.grid(row=10, column=3)
entry_information_number_103.after(100, entry_information_number_103_upgrade)
entry_information_number_113 = tk.Entry(frame_button, width=5)
entry_information_number_113.grid(row=11, column=3)
entry_information_number_113.after(100, entry_information_number_113_upgrade)
entry_information_number_123 = tk.Entry(frame_button, width=5)
entry_information_number_123.grid(row=12, column=3)
entry_information_number_123.after(100, entry_information_number_123_upgrade)
entry_information_number_133 = tk.Entry(frame_button, width=5)
entry_information_number_133.grid(row=13, column=3)
entry_information_number_133.after(100, entry_information_number_133_upgrade)
entry_information_number_143 = tk.Entry(frame_button, width=5)
entry_information_number_143.grid(row=14, column=3)
entry_information_number_143.after(100, entry_information_number_143_upgrade)
entry_information_number_153 = tk.Entry(frame_button, width=5)
entry_information_number_153.grid(row=15, column=3)
entry_information_number_153.after(100, entry_information_number_153_upgrade)
entry_information_number_24 = tk.Entry(frame_button, width=11)
entry_information_number_24.grid(row=2, column=4)
entry_information_number_24.after(100, entry_information_number_24_upgrade)
entry_information_number_34 = tk.Entry(frame_button, width=11)
entry_information_number_34.grid(row=3, column=4)
entry_information_number_34.after(100, entry_information_number_34_upgrade)
entry_information_number_44 = tk.Entry(frame_button, width=11)
entry_information_number_44.grid(row=4, column=4)
entry_information_number_44.after(100, entry_information_number_44_upgrade)
entry_information_number_54 = tk.Entry(frame_button, width=11)
entry_information_number_54.grid(row=5, column=4)
entry_information_number_54.after(100, entry_information_number_54_upgrade)
entry_information_number_64 = tk.Entry(frame_button, width=11)
entry_information_number_64.grid(row=6, column=4)
entry_information_number_64.after(100, entry_information_number_64_upgrade)
entry_information_number_74 = tk.Entry(frame_button, width=11)
entry_information_number_74.grid(row=7, column=4)
entry_information_number_74.after(100, entry_information_number_74_upgrade)
entry_information_number_84 = tk.Entry(frame_button, width=11)
entry_information_number_84.grid(row=8, column=4)
entry_information_number_84.after(100, entry_information_number_84_upgrade)
entry_information_number_94 = tk.Entry(frame_button, width=11)
entry_information_number_94.grid(row=9, column=4)
entry_information_number_94.after(100, entry_information_number_94_upgrade)
entry_information_number_104 = tk.Entry(frame_button, width=11)
entry_information_number_104.grid(row=10, column=4)
entry_information_number_104.after(100, entry_information_number_104_upgrade)
entry_information_number_114 = tk.Entry(frame_button, width=11)
entry_information_number_114.grid(row=11, column=4)
entry_information_number_114.after(100, entry_information_number_114_upgrade)
entry_information_number_124 = tk.Entry(frame_button, width=11)
entry_information_number_124.grid(row=12, column=4)
entry_information_number_124.after(100, entry_information_number_124_upgrade)
entry_information_number_134 = tk.Entry(frame_button, width=11)
entry_information_number_134.grid(row=13, column=4)
entry_information_number_134.after(100, entry_information_number_134_upgrade)
entry_information_number_144 = tk.Entry(frame_button, width=11)
entry_information_number_144.grid(row=14, column=4)
entry_information_number_144.after(100, entry_information_number_144_upgrade)
entry_information_number_154 = tk.Entry(frame_button, width=11)
entry_information_number_154.grid(row=15, column=4)
entry_information_number_154.after(100, entry_information_number_154_upgrade)
entry_information_number_25 = tk.Entry(frame_button, width=12)
entry_information_number_25.grid(row=2, column=5)
entry_information_number_25.after(100, entry_information_number_25_upgrade)
entry_information_number_35 = tk.Entry(frame_button, width=12)
entry_information_number_35.grid(row=3, column=5)
entry_information_number_35.after(100, entry_information_number_35_upgrade)
entry_information_number_45 = tk.Entry(frame_button, width=12)
entry_information_number_45.grid(row=4, column=5)
entry_information_number_45.after(100, entry_information_number_45_upgrade)
entry_information_number_55 = tk.Entry(frame_button, width=12)
entry_information_number_55.grid(row=5, column=5)
entry_information_number_55.after(100, entry_information_number_55_upgrade)
entry_information_number_65 = tk.Entry(frame_button, width=12)
entry_information_number_65.grid(row=6, column=5)
entry_information_number_65.after(100, entry_information_number_65_upgrade)
entry_information_number_75 = tk.Entry(frame_button, width=12)
entry_information_number_75.grid(row=7, column=5)
entry_information_number_75.after(100, entry_information_number_75_upgrade)
entry_information_number_85 = tk.Entry(frame_button, width=12)
entry_information_number_85.grid(row=8, column=5)
entry_information_number_85.after(100, entry_information_number_85_upgrade)
entry_information_number_95 = tk.Entry(frame_button, width=12)
entry_information_number_95.grid(row=9, column=5)
entry_information_number_95.after(100, entry_information_number_95_upgrade)
entry_information_number_105 = tk.Entry(frame_button, width=12)
entry_information_number_105.grid(row=10, column=5)
entry_information_number_105.after(100, entry_information_number_105_upgrade)
entry_information_number_115 = tk.Entry(frame_button, width=12)
entry_information_number_115.grid(row=11, column=5)
entry_information_number_115.after(100, entry_information_number_115_upgrade)
entry_information_number_125 = tk.Entry(frame_button, width=12)
entry_information_number_125.grid(row=12, column=5)
entry_information_number_125.after(100, entry_information_number_125_upgrade)
entry_information_number_135 = tk.Entry(frame_button, width=12)
entry_information_number_135.grid(row=13, column=5)
entry_information_number_135.after(100, entry_information_number_135_upgrade)
entry_information_number_145 = tk.Entry(frame_button, width=12)
entry_information_number_145.grid(row=14, column=5)
entry_information_number_145.after(100, entry_information_number_145_upgrade)
entry_information_number_155 = tk.Entry(frame_button, width=12)
entry_information_number_155.grid(row=15, column=5)
entry_information_number_155.after(100, entry_information_number_155_upgrade)
frame_upgrade = tk.Frame(root)
frame_upgrade.grid(row=2, column=2)
statistics_text_label = tk.Label(frame_upgrade, text="Statistics") # 统计信息框
statistics_text_label.grid(row=1, column=1, pady=2)
statistics_text_label = tk.Label(frame_upgrade, text="Upgrades")
statistics_text_label.grid(row=1, column=3, columnspan=2, pady=2, padx=100)
statistics_text = tk.Text(frame_upgrade, height=8, width=40, font=("", 11))
statistics_text.grid(row=2, column=1, rowspan=10)
statistics_text.after(100, statistics_text_upgrade)
statistics_button_2 = tk.Button(frame_upgrade, text="Upgrade", width=10, height=2, command=upgrade_button_clicked)
statistics_button_2.grid(row=2, column=3, rowspan=2, sticky='e')
statistics_button_entry = tk.Entry(frame_upgrade)
statistics_button_entry.grid(row=2, column=4)
statistics_button_entry.after(100, statistics_button_entry_update)
statistics_button_entry_price = tk.Entry(frame_upgrade)
statistics_button_entry_price.grid(row=3, column=4, sticky='n')
statistics_button_entry_price.after(100, statistics_button_entry_price_update)
frame_bottom = tk.Frame(root)
frame_bottom.grid(row=3, column=1, columnspan=2)
level_progress_label_left = tk.Entry(frame_bottom, width=7, borderwidth=1, justify='center') # 等级进度条
level_progress_label_left.grid(row=1, column=0)
level_progress_label_left.after(100, level_progress_label_left_update)
level_progress_bar = ttk.Progressbar(frame_bottom, length=250, orient='horizontal', mode='determinate')
level_progress_bar.grid(row=1, column=1)
level_progress_bar.after(100, level_progress_bar_update)
level_progress_label_right = tk.Entry(frame_bottom, width=7, borderwidth=1, justify='center')
level_progress_label_right.grid(row=1, column=2)
level_progress_label_right.after(100, level_progress_label_right_update)
achievements_information_text = tk.Text(frame_button, width=35, height=31) # 成就框
achievements_information_text.grid(row=2, column=6, rowspan=14)
entry_information_information = tk.Entry(frame_bottom,
width=80,
justify='center')
entry_information_information.grid(row=1, column=4,
ipady=1, pady=5, padx=50)
entry_information_information.after(100, entry_information_information_upgrade)
frame_bottom_left = tk.Frame(frame_bottom)
frame_bottom_left.grid(row=1, column=10)
bottom_button_download = tk.Button(frame_bottom_left, # 底部按钮
text="Save..",
width=8, height=1, pady=3,
command=window_download)
bottom_button_download.grid(row=1, column=2, sticky='w')
bottom_button_upload = tk.Button(frame_bottom_left,
text="Upload..",
width=10, height=1, pady=3,
command=window_upload)
bottom_button_upload.grid(row=1, column=3, sticky='w')
bottom_button_about = tk.Button(frame_bottom_left,
text="About..",
width=9, height=1, pady=3,
command=window_about)
bottom_button_about.grid(row=1, column=4, sticky='w')
bottom_button_about = tk.Button(frame_bottom_left,
text="Exit..",
width=8, height=1, pady=3,
command=root_close)
bottom_button_about.grid(row=1, column=5, sticky='w')
def aaaaa():
def hello(self):
"""
:param self:
"""
print("hello!")
menubar = Menu(root, bg="red")
root.config(menu=menubar)
def add():
print("相加")
def subtract():
print("相减")
def multiply():
print("相乘")
def divide():
print("相除")
# 创建下拉菜单,并添加到菜单条
operationMenu = Menu(menubar, tearoff=0)
menubar.add_cascade(label="About…", menu=operationMenu)
operationMenu.add_command(label="加", command=add)
operationMenu.add_command(label="减", command=subtract)
operationMenu.add_separator()
operationMenu.add_command(label="乘", command=multiply)
operationMenu.add_command(label="除", command=divide)
exitMenu = Menu(menubar, tearoff=0)
menubar.add_cascade(label="退出", menu=exitMenu)
exitMenu.add_command(label="退出", command=root.quit)
mainloop()
root.mainloop()