VS code 配置 PySide6的UI开发环境

VS code 配置 PySide6的UI开发环境,第1张

安装好VS Code 和 PySide6后,困歼安装扩展 Qt for Python.

需要用到以下命令在 cmd中 找到相关路径:

where python

pip show PySide6

得到路径后,填入以下设置中:

{

    "qtForPython.uic.path": "c:\\programdata\\anaconda3\\lib\森尺拆\site-packages\\PySide6\\uic.exe",

    "此枣qtForPython.designer.path": "c:\\programdata\\anaconda3\\lib\\site-packages\\PySide6\\designer.exe",

    "qtForPython.rcc.path": "c:\\programdata\\anaconda3\\lib\\site-packages\\PySide6\\rcc.exe",

}

c语言制作UI界面需要相关的UI库

如windows *** 作系统本身就提供了UI的接口

一个简单的示例代码如下

#include <windows.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM)

int WINAPI WinMain(HINSTANCE hinstance,HINSTANCE hprevinstance,LPSTR line,int cmd)

{

    static TCHAR AppName[]=TEXT("99")

    HWND hwnd

    MSG msg

    WNDCLASS wndclass

    

    wndclass.style=CS_HREDRAW|CS_VREDRAW

    wndclass.lpfnWndProc=WndProc

    wndclass.cbClsExtra=0

    wndclass.cbWndExtra=0

    wndclass.hInstance=hinstance

    wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION)

  弯碧启  wndclass.hCursor=LoadCursor(NULL,IDC_ARROW)

    wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH)

    wndclass.lpszMenuName=NULL

    wndclass.lpszClassName=AppName

    

    if(!RegisterClass(&wndclass))

    {

        MessageBox(NULL,TEXT("This program requires Windows NT!"),AppName,MB_ICONERROR)

        return 0

    }

    

    hwnd=CreateWindow(AppName,TEXT("九九乘法口诀表"),\

        WS_OVERLAPPEDWINDOW,\

        CW_USEDEFAULT,\

        CW_USEDEFAULT,\

        CW_USEDEFAULT,\

        CW_USEDEFAULT,\

   慧脊     NULL,\

        NULL,\

        hinstance,\

        NULL)

        

    ShowWindow(hwnd,cmd)

    UpdateWindow(hwnd)

    

    while(GetMessage(&msg,NULL,0,0))

    {

        TranslateMessage(&msg)

        DispatchMessage(&msg)

    }

    

    return msg.wParam

}

LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam)

{

    HDC hdc

    PAINTSTRUCT ps

    RECT rect

    static x,y

    int i,j

    int len

    TCHAR buf[50]

    TEXTMETRIC tm

    

    switch(message)

    {

        case WM_CREATE:

            hdc=GetDC(hwnd)

            GetTextMetrics(hdc,&tm)

            x=tm.tmAveCharWidth

            y=tm.tmHeight+tm.tmExternalLeading

            ReleaseDC(hwnd,hdc)

            //MessageBox(NULL,TEXT("Create Successed!"),TEXT("Successed"),MB_OK)

            //PlaySound(TEXT("hello.wav"),NULL,SND_FILENAME|SND_ASYNC)

            return 0

            

        case WM_PAINT:

            hdc=BeginPaint(hwnd,&ps)

            GetClientRect(hwnd,&rect)

            //DrawText(hdc,TEXT("Hello World!"),-1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER)

            //TextOut(hdc,rect.right/2-(strlen("Hello World!")/2)*x,rect.bottom/2-y/2,TEXT("Hello World!"),12)

            for(i=1i!=10++i)

            {

                for(j=1j!=i+1++j)

                {

                    len=wsprintf(buf,TEXT("埋如%dx%d=%-4d"),j,i,i*j)

                    TextOut(hdc,j*len*x,i*y,buf,len)

                }

            }

            

            EndPaint(hwnd,&ps)

            return 0

            

        case WM_DESTROY:

            PostQuitMessage(0)

            return 0

    }

    

    return DefWindowProc(hwnd,message,wparam,lparam)

}

上面是一个打印windows下拥有窗口界面的九九乘法口诀表的c语言程序代码

同样的c语言也会有其它的UI库

比如Gtk,Gtk是可移植的UI库

可以使用它在Linux、windows包括mac等等 *** 作系统上做ui程序设计

一个简单的示例代码如下

#include <gtk/gtk.h>

int main(int argc,char **argv)

{

    GtkWidget *win

    GtkWidget *label

    int i,j

    GString *str

    gtk_init(&argc,&argv)

    win=gtk_window_new(GTK_WINDOW_TOPLEVEL)

    gtk_window_set_position(GTK_WINDOW(win),GTK_WIN_POS_CENTER)

    g_signal_connect(G_OBJECT(win),"delete-event",G_CALLBACK(gtk_main_quit),NULL)

    str=g_string_new(NULL)

    for(i=1i <= 9++i)

    {

        for(j=1j != i+1++j)

            g_string_append_printf(str,"%dx%d=%-4d",j,i,i*j)

        g_string_append(str,"\n")

    }

    label=gtk_label_new(str->str)

    gtk_container_add(GTK_CONTAINER(win),label)

    gtk_widget_show_all(win)

    gtk_main()

    g_string_free(str,TRUE)

    return 0

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12318215.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存