热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

python创建一个窗口_等一个大佬啊要求用python创建一个窗口,窗口按钮功能是创建一个球体或立方体。明天上课之前交给我...

展开全部下面的代码是创建一个立方体Thisexamplescreatesanddisplaysasimplebox.#Thefirstlineloadstheinit_disp

展开全部

下面的代码是创建一个立方体'''

This examples creates and displays a simple box.

'''

# The first line loads the init_display function, necessary to

# enable the builtin simple gui provided with pythonocc

from OCC.Display.SimpleGui import init_display

# Then we import the class that instanciates a box

# Here the BRepPrimAPI module means Boundary Representation Primitive API.

# It provides an API for creation of basic geometries like spheres,cones etc

from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox

# Following line initializes the display

# By default, the init_display function looks for a Qt based Gui (PyQt, PySide)

display, start_display, add_menu, add_function_to_menu = init_display()

# The BRepPrimAPI_MakeBox class is initialized with the 3 parameters of the box: widht, height, depth

my_box = BRepPrimAPI_MakeBox(10., 20., 30.).Shape()

# Then the box shape is sent to the renderer

display.DisplayShape(my_box, update=True)

# At last, we enter the gui mainloop

start_display()

创建页面#coding:utf8

import wx

app = wx.App() #创建对象62616964757a686964616fe59b9ee7ad9431333363373738

win = wx.Frame(None,title="ahuang1900", size=(410,340)) #创建窗口对象

wx.Button(win, label="open", pos = (245,5), size=(80,25)) #创建按钮1

wx.Button(win, label="save", pos = (325,5), size=(80,25)) #创建按钮2

wx.TextCtrl(win, pos=(5,5), size=(240,25)) #创建文本框1

#创建文本框2

wx.TextCtrl(win, pos=(5,35), size=(400,300), style=wx.TE_MULTILINE|wx.HSCROLL)

win.Show() #显示

app.MainLoop() #主事件循环



推荐阅读
author-avatar
一滴水
没事就吐槽!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有