您的位置:首页 > 新闻 > 资讯 > 郑州设计公司招聘_广告公司的组织架构图_怎么弄自己的网站_网站如何优化

郑州设计公司招聘_广告公司的组织架构图_怎么弄自己的网站_网站如何优化

2025/2/23 21:17:40 来源:https://blog.csdn.net/u014584014/article/details/145774667  浏览:    关键词:郑州设计公司招聘_广告公司的组织架构图_怎么弄自己的网站_网站如何优化
郑州设计公司招聘_广告公司的组织架构图_怎么弄自己的网站_网站如何优化

pythonnet 是pythonhe.net通用的神器不多介绍了.  

这次这基本上跟python没有关系了.

和winform一样先导包

import clr
clr.AddReference("PresentationFramework.Classic, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
clr.AddReference("PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")from System.Windows import Application
from System.Windows import Window
from System.Windows import MessageBox
from System.Windows import LogicalTreeHelper
from System.Windows.Markup import XamlReader
from System.Threading import Thread
from System.Threading import ApartmentState
from System.Threading import ThreadStart
from System import *

哈哈哈 有没有感觉和 C#一样.

using System;
using SC = System.Console;

是不是一模一样;

接下来:  写个类.  当然你可以用C#  VB.net单独做 成DLL也没关系. 重要的是先把婚结了 孩子生出来.  不对 先把东西生产出来.

class MainWindow(Window):def __init__(self):Window.__init__(self)#  XAMLxaml = """<Pagexmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Grid>  <Grid.RowDefinitions><RowDefinition/><RowDefinition/></Grid.RowDefinitions><Button Name="Button1" Grid.Row="0">Button 1</Button><Button Name="Button2" Grid.Row="1">Button 2</Button></Grid></Page>"""page = XamlReader.Parse(xaml)# connect Button1self.Button1 = LogicalTreeHelper.FindLogicalNode(page, "Button1")self.Button1.Click += self.Button1_Click# connect Button2self.Button2 = LogicalTreeHelper.FindLogicalNode(page, "Button2")self.Button2.Click += self.Button2_Click# self.Title = "Python WPF App with XAML!"self.Width = 350self.Height = 300self.Content = pagedef Button1_Click(self, sender, e):MessageBox.Show(self.Button1.Content + " is clicked!")def Button2_Click(self, sender, e):MessageBox.Show(self.Button2.Content + " is clicked!")

def STAMain():app = Application()app.Run(MainWindow())def main():t = Thread(ThreadStart(STAMain))t.ApartmentState = ApartmentState.STAt.Start()t.Join()if __name__ == "__main__":main()

界面一定要线程里面; 要不然python解释器会卡死.

当然 你也可以这么干;用C#界面类库打包写成DLL在用python调用. python只管传参数.

对于性能要求不高的场合就很合适.

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com