python菜单
⑴ python要编写一个完整的程序,需要创建新的文件。应该选择什么菜单创建
从用户获取文件名并创建同名文件的函数。然后,函数应该使用while循环来处理文件,并允许用户输入要写入文件的多个整数。
使用for循环读取文件内容并将其输出到屏幕的函数。
向文件中追加若干整数的函数。
计算文件中包含的数字总数并打印
⑵ 为什么python窗体里菜单与简单计算器两者显示不出来
检查mac菜单栏和代码。
python窗体里菜单代码运行良好缺不显示的话,可以检查mac菜单栏,需要单击窗体,会显示一个下拉菜单栏,这样菜单就会显示了,简单计算器显示不出来可能是代码出现错误,例如重复运算符金额小数点出现错误,建议检查代码有没有出错。
⑶ python tkinter 做一个菜单
你这不是菜单,你这是下拉列表框,combobox控件。tkinter默认是不带的。
但是TKINTER有一个“隐藏功能”,导入ttk主题库后,你就可以用ComboBox等高级控件了。
给你个例子,你就知道怎么写了。
# -*- coding: UTF-8 -*-
# 获取ODBC数据源列表
from tkinter import *
from tkinter import ttk
import win32api,win32con
def GetODBCdsn():
key = win32api.RegOpenKey(win32con.HKEY_CURRENT_USER,
'SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',0, win32con.KEY_ALL_ACCESS)
#print(key)
#print(win32api.RegQueryValue(key,''))
#print('返回项的子项数目、项值数目,以及最后一次修改时间',win32api.RegQueryInfoKey(key))
subitem, item, opdate =win32api.RegQueryInfoKey(key)
dsnlist=[]
for i in range(item):
print('---',win32api.RegEnumValue(key, i))
dsnName,dsnObject,dsnType = win32api.RegEnumValue(key, i)
dsnlist.append(dsnName)
#print(dir(win32api))
win32api.RegCloseKey(key)
return dsnlist
class MFrame(Frame):
def __init__(self, master=None, cnf={}, **kw):
self.master = master
self.master.title('获取用户定义的数据源')
self.combo = ttk.Combobox(self.master)
self.combo.config(state="readonly")
self.combo.pack(side=TOP, fill = 'x', expand = False)
self.combo.update_idletasks()
comlist=GetODBCdsn()
self.combo['values'] = comlist
def test():
GetODBCdsn()
def main():
root = Tk()
mf=MFrame(root)
root.mainloop()
if __name__=="__main__":
#test()
main()
⑷ python怎么使用
Python是一种计算机程序设计语言,也是人工智能时代的语言,初的时候是被设计用于编写自动化脚本,但是现在随着版本的不断更新以及其他功能的添加,现在 Python已经被广泛的应用于ー些大型开发上面。在少儿编程领域,Python也逐渐成为孩子们深入系统学习编程的基础语言。
⑸ python菜单程序
你不是用qt开发界面的也不是用tkinter开发
只是原始的代码的话
最简单的方法是用
if
else if
else if
else
这样的,在python里面貌似没有类似C语言的swtich
所以还是用最基本的方法吧
这个对于有一点的编程基础的同学来的话是相当简单的
python以她代码精简精悍闻名,所以越到后面你会体会到的
当然还有其他方法实现你说的,对于初学者的你我建议你还是把if学好,基本的判断在任何语言中都是基础的
/************************电泡泡**************************/
ps:有疑问请直接hi我,或者email [email protected],对了我可以推荐一些python的教材和视频给你
望采纳..
⑹ 下载Python后右键菜单变长
这并不会影响你的操作,如果你是强迫证的话还是需要改的,
解决方法是:在安装的时候不要选择Add lauchers dir to the PATH 就行了
另外安装PYCharm后右键打开桌面项目导致菜单栏变宽解决方法是运行regedit注册表; 按以下路径,HKEY_CLASSES_ Community Edition ,找到PyCharm Community Edition文件夹,删除.即可
⑺ python游戏菜单问题,本人python小白,求大佬解决帮一下
while True:
num = ('1','2','3','4','0')
menu = ('游戏设置','选择游戏级别','我的装备','我的积分','退出')
mapping = dict(zip(num, menu))
print('
'.join(['.'.join(x) for x in mapping.items()]))
choice = input('请输入菜单项对应的数字:')
print(mapping.get(choice, '选项不存在') if choice!='0' else '谢谢使用', end='
')
if choice == '0':
break
⑻ python文本菜单的程序
#!/usr/bin/envpython3#py3.6+
"""
#要求做一个系统菜单,输入数字进入对应菜单,包含以下内容,正常操作不能报错:
#菜单1:打印所有产品价格和库存
#菜单2:修改产品价格
#菜单3:增加库存
#菜单4:购买指定数量产品
#菜单5:增加新产品作为思考题
#菜单0:退出当前系统
"""
price={'vegetables':'3','eggs':'4','rice':'2'}#价格dict
stock={'vegetables':'0','eggs':'0','rice':'0'}#库存dict
tip='''
1:打印所有产品价格和库存
2:修改产品价格
3:增加库存
4:购买指定数量产品
5:增加新产品作为思考题
0:退出当前系统
'''
defmain():
whileTrue:
globalprice,stock
a=input(f'Pleaseenteranumber:{tip} ').strip()
ifa=='0':
print('Exit!')
break
elifa=='1':
style='{:15}{:6}{:5}'
print(style.format('Name','price','stock'))
for(n,p),(_,s)inzip(price.items(),stock.items()):
print(style.format(n,p,s))
print()
elifa=='2':
whileTrue:
n=input(':')
ifninprice:
break
print('invalidinput!Shouldbe"{}".'.format(
'"or"'.join(price)))
p=input('enteranewpriceofthisproct:')
price[n]=p
elifa=='3':
whileTrue:
n=input(':')
ifninstock:
break
print('Invalidinput!Shouldbe"{}".'.format(
'"or"'.join(stock)))
whileTrue:
s=input(':')
try:
s=int(s)
break
except:
print('Invalidinput,mustbeainteger!')
stock[n]=str(int(stock[n])+s)
elifa=='4':
whileTrue:
n=input('enteraproctnametobuyit:')
ifninstock:
break
print('Invalidinput!Shouldbe"{}".'.format(
'"or"'.join(stock)))
whileTrue:
s=input('enteraintegerforhowmanytobuy:')
try:
s=int(s)
ifs<=0ors>int(stock[n]):
raise
break
except:
print('Invalidinput,mustbeapositiveintegerand'
'lessthan{}!'.format(stock[n]))
y=input('Youwanttobuy{}X{},whichcost{}?(y)/n'.format(
n,s,int(price[n])*s))
ify.strip().lower()in('y',''):
stock[n]=str(int(stock[n])-s)
print('Youpay{}andget{}{}'.format(int(price[n]*s),s,n))
elifa=='5':
print('Uncomplete... ')
if__name__=='__main__':
main()