public aa(){//构造方法不要加void
JFrame f=new JFrame("菜单组件");
JMenuBar bar =new JMenuBar();
JMenuItem j1=new JMenuItem("Open");
JMenuItem j2=new JMenuItem("Save");
JMenuItem j3=new JMenuItem("Save as Template");
JMenu m1 = new JMenu("File");
mypanel mp=new mypanel();
fadd(bar);
fsetJMenuBar(bar);//this改成f
baradd(m1);
m1add(j1);
m1add(j2);
m1add(j3);
fsetSize(800,600);
fsetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);
fpack();
fsetVisible(true);
}
#!/usr/bin/env python3 # py 36+
"""
#要求做一个系统菜单,输入数字进入对应菜单,包含以下内容,正常 *** 作不能报错:
# 菜单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:退出当前系统
'''
def main():
while True:
global price, stock
a = input(f'Please enter a number:{tip}\n')strip()
if a == '0':
print('Exit!')
break
elif a == '1':
style = '{:15}{:6}{:5}'
print(styleformat('Name', 'price', 'stock'))
for (n, p), (_, s) in zip(priceitems(), stockitems()):
print(styleformat(n, p, s))
print()
elif a == '2':
while True:
n = input('enter a product name to modify its price: ')
if n in price:
break
print('invalid input! Should be "{}"'format(
'" or "'join(price)))
p = input('enter a new price of this product: ')
price[n] = p
elif a == '3':
while True:
n = input('enter a product name to increase its stock: ')
if n in stock:
break
print('Invalid input! Should be "{}"'format(
'" or "'join(stock)))
while True:
s = input('enter a integer to update the stock of it: ')
try:
s = int(s)
break
except:
print('Invalid input, must be a integer!')
stock[n] = str(int(stock[n]) + s)
elif a == '4':
while True:
n = input('enter a product name to buy it: ')
if n in stock:
break
print('Invalid input! Should be "{}"'format(
'" or "'join(stock)))
while True:
s = input('enter a integer for how many to buy: ')
try:
s = int(s)
if s <=0 or s > int(stock[n]):
raise
break
except:
print('Invalid input, must be a positive integer and '
'less than{}!'format(stock[n]))
y = input('You want to buy {} X {}, which cost {} (y)/n 'format(
n, s, int(price[n]) s))
if ystrip()lower() in ('y', ''):
stock[n] = str(int(stock[n]) - s)
print('You pay {} and get {} {}'format(int(price[n]s), s, n))
elif a == '5':
print('Uncomplete\n')
if __name__ == '__main__':
main()
以上就是关于3ds Max为什么我用脚本编了菜单程序,重新运行,菜单栏还是不显示程序(程序如下)全部的内容,包括:3ds Max为什么我用脚本编了菜单程序,重新运行,菜单栏还是不显示程序(程序如下)、python文本菜单的程序、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)