نمایش نتایج 1 تا 9 از 9

نام تاپیک: ویندوز فرم اپلیکیشن در پایتون؟

  1. #1
    کاربر دائمی آواتار حسین شهریاری
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ایران
    پست
    797

    Question ویندوز فرم اپلیکیشن در پایتون؟

    با سلام
    آیا توی محیط ویژوال استادیو دات نت(مثلا 2019 یا 2022) میشه با پایتون برنامه نویسی ویژوال انجام داد، مثل سی شارپ؟
    یعنی طراحی فرم وجود داره یا نه باید مثل #F کدنویسی کنیم؟

  2. #2
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    نقل قول: ویندوز فرم اپلیکیشن در پایتون؟

    سلام و روز خوش

    من با powershell رو که میدونم میشه
    چون انجام دادم،
    با اینحساب با پایتون که قطعا میشه.

    برای نمونه کد از هوش ساختگی کمک بگیرین.

  3. #3
    کاربر دائمی آواتار حسین شهریاری
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ایران
    پست
    797

    نقل قول: ویندوز فرم اپلیکیشن در پایتون؟

    سلام
    ممنون، هوش ساختگی یاست خاصیه؟ اگه ممکنه لینک بدید.

  4. #4
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    نقل قول: ویندوز فرم اپلیکیشن در پایتون؟

    سلام دوباره

    شما میتونین از چند هوش ساختگی برای ساخت نمونه کدهایی از این دست استفاده کنین:
    مثل Microsoft Copilot , DeepSeek , Google DeepMind (Gemini) , Grok
    که همشون هم بروزر اینترفیس دارن (همین اسمهای بالا رو سرچ کنین) و هم اینکه رایگان هم خیلی خوب جواب میدن.

    من با نمونه پرامپت زیر:
    Create a Python program that makes a WinForms form 
    with a textbox (named as "TxtBox")
    and a button (named as "Btn" with caption="Click!").
    In the Btn_Click event, close the form
    and return control to the Python script
    which should display the text entered in `TxtBox` in a message box.


    پاسخ های زیر گرفتم که براتون میذارم - چون پایتون کار نمیکنم در مورد میزان درستی پاسخ ها ایده ای ندارم و تست رو میذارم به عهده خودتون،
    ولی معمولا اگر پرسش های دقیق و شفاف مطرح کنین پاسخ خوبی میگیرین،
    و گاهی لازمه ویرایش کنین یا در چت ادامه بدین.

  5. #5
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    Copilot answer to: WinForms in Python

    Here’s a Python script that uses the `pythonnet` library to create a WinForms application. 
    The program creates a form with a textbox (`TxtBox`) and a button (`Btn`).
    When the button is clicked, the form closes, and the text entered in `TxtBox` is displayed in a message box:

    ```python
    import clr
    clr.AddReference("System.Windows.Forms")
    from System.Windows.Forms import Application, Form, Button, TextBox, MessageBox


    class MyForm(Form):
    def __init__(self):
    self.Text = "WinForms Example"
    self.Width = 300
    self.Height = 150


    # Create a TextBox
    self.TxtBox = TextBox()
    self.TxtBox.Top = 20
    self.TxtBox.Left = 20
    self.TxtBox.Width = 240
    self.Controls.Add(self.TxtBox)


    # Create a Button
    self.Btn = Button()
    self.Btn.Text = "Click!"
    self.Btn.Top = 60
    self.Btn.Left = 20
    self.Btn.Click += self.Btn_Click
    self.Controls.Add(self.Btn)


    def Btn_Click(self, sender, event):
    self.Close()


    def main():
    form = MyForm()
    Application.Run(form)
    # After the form closes, retrieve the text from the textbox
    entered_text = form.TxtBox.Text
    MessageBox.Show(f"You entered: {entered_text}")


    if __name__ == "__main__":
    main()
    ```


    ### Key Points:
    1. **Dependencies**: This script uses `pythonnet` to access .NET libraries. You can install it via pip: `pip install pythonnet`.
    2. **Structure**: The `MyForm` class defines the WinForms UI with a textbox and a button.
    3. **Event Handling**: The `Btn_Click` method handles the button click event, closes the form, and control returns to the main Python script.
    4. **Message Display**: After the form closes, the script displays the entered text in a message box.


    Let me know if you'd like me to explain any part of it further!


    https://copilot.microsoft.com/shares...wrn2KntmejGJ8r
    آخرین ویرایش به وسیله mazoolagh : یک شنبه 31 فروردین 1404 در 19:09 عصر

  6. #6
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    Grok answer to: WinForms in Python

    To create a Python program that uses WinForms to display a form with a textbox and a button, 
    and then shows the entered text in a message box after the form closes,
    we can use the `pythonnet` library (`clr` module) to interact with .NET's Windows Forms.
    The program will create a form with a textbox named "TxtBox"
    and a button named "Btn" with the caption "Click!".
    When the button is clicked, the form closes, and the Python script displays the textbox's text in a message box.

    Since this involves .NET's Windows Forms,
    the code assumes a Windows environment with `pythonnet` installed (`pip install pythonnet`).
    The `System.Windows.Forms` assembly will be used for the form and message box,
    and the button's click event will trigger the form's closure.
    The textbox's text will be stored in a variable accessible to the main script for display in a message box.


    Here is the Python program:


    ```python
    import clr
    clr.AddReference("System.Windows.Forms")
    from System.Windows.Forms import Application, Form, TextBox, Button, MessageBox


    class MyForm(Form):
    def __init__(self):
    super().__init__()
    self.Text = "Input Form"
    self.Width = 300
    self.Height = 200

    # Create and configure the textbox
    self.TxtBox = TextBox()
    self.TxtBox.Name = "TxtBox"
    self.TxtBox.Location = System.Drawing.Point(50, 30)
    self.TxtBox.Size = System.Drawing.Size(200, 20)
    self.Controls.Add(self.TxtBox)

    # Create and configure the button
    self.Btn = Button()
    self.Btn.Name = "Btn"
    self.Btn.Text = "Click!"
    self.Btn.Location = System.Drawing.Point(50, 70)
    self.Btn.Size = System.Drawing.Size(100, 30)
    self.Btn.Click += self.Btn_Click
    self.Controls.Add(self.Btn)

    # Variable to store textbox text
    self.entered_text = ""

    def Btn_Click(self, sender, args):
    # Store the textbox text and close the form
    self.entered_text = self.TxtBox.Text
    self.Close()


    def main():
    # Create and run the form
    form = MyForm()
    Application.Run(form)

    # After form closes, show the entered text in a message box
    MessageBox.Show(f"Text entered: {form.entered_text}", "Result")


    if __name__ == "__main__":
    main()
    ```


    https://grok.com/share/bGVnYWN5_a73f...f-4dda4cbb7ec6

  7. #7
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    DeepSeek answer to: WinForms in Python

    # Python WinForms Application with TextBox and Button

    Here's a Python program that creates a WinForms application with a textbox and a button.
    When the button is clicked, the form closes and the entered text is displayed in a message box:


    ```python
    import clr
    clr.AddReference("System.Windows.Forms")
    clr.AddReference("System.Drawing")


    from System.Windows.Forms import (
    Application, Form, Button, TextBox,
    MessageBox, DialogResult
    )
    from System.Drawing import Point, Size


    class MyForm(Form):
    def __init__(self):
    self.Text = "WinForms Example"
    self.ClientSize = Size(300, 150)

    # Create textbox
    self.TxtBox = TextBox()
    self.TxtBox.Location = Point(50, 30)
    self.TxtBox.Size = Size(200, 20)
    self.Controls.Add(self.TxtBox)

    # Create button
    self.Btn = Button()
    self.Btn.Text = "Click!"
    self.Btn.Location = Point(100, 70)
    self.Btn.Size = Size(100, 30)
    self.Btn.Click += self.Btn_Click
    self.Controls.Add(self.Btn)

    # Store the result
    self.entered_text = None

    def Btn_Click(self, sender, event):
    self.entered_text = self.TxtBox.Text
    self.Close()


    def main():
    form = MyForm()
    Application.Run(form)

    # After form closes, show the entered text
    if form.entered_text is not None:
    MessageBox.Show(
    f"You entered: {form.entered_text}",
    "Result",
    MessageBoxButtons.OK,
    MessageBoxIcon.Information
    )
    else:
    MessageBox.Show(
    "No text was entered",
    "Result",
    MessageBoxButtons.OK,
    MessageBoxIcon.Information
    )


    if __name__ == "__main__":
    main()
    ```


    ## How This Works:


    1. The code creates a WinForms application using Python.NET (`clr` module).
    2. The form contains:
    - A `TextBox` named `TxtBox`
    - A `Button` named `Btn` with text "Click!"
    3. When the button is clicked:
    - The text from `TxtBox` is stored in the form's `entered_text` property
    - The form closes
    4. After the form closes, the main script displays the entered text in a message box


    ## Requirements:
    - You need to have Python.NET installed (`pip install pythonnet`)
    - This runs on Windows with .NET Framework


    The message box will show exactly what was entered in the textbox when the form was closed.

  8. #8
    کاربر دائمی آواتار حسین شهریاری
    تاریخ عضویت
    اسفند 1387
    محل زندگی
    ایران
    پست
    797

    نقل قول: ویندوز فرم اپلیکیشن در پایتون؟

    ممنون از دقت شما
    پس حتما باید با کدنویسی این کار انجام بشه؟
    مثل سی شارپ و وی بی فرم دیزاین نداره؟

  9. #9
    کاربر دائمی آواتار mazoolagh
    تاریخ عضویت
    اردیبهشت 1384
    سن
    72
    پست
    3,555

    نقل قول: ویندوز فرم اپلیکیشن در پایتون؟

    فکر نمیکنم هیچ IDE برای پایتون چنین قابلیتی داشته باشه،
    چون در نهادش برای این کار نیست.

    شما فرم رو در visual studio بسازین،
    بعد کد designer رو کپی کنین تو اسکریپت خودتون (مشخصا نیاز به ادیت داره - از نمونه کدهای بالا ایده بگیرین)

تاپیک های مشابه

  1. محل ذخیره بکاپ آیتونز در ویندوز 10 و نحوه جابه‌جایی آن‌ها
    نوشته شده توسط elahe4321n در بخش بک لینک (Back Links)
    پاسخ: 0
    آخرین پست: دوشنبه 28 فروردین 1402, 10:33 صبح
  2. سوال: نصب نشدن پایتون در ویندوز 7
    نوشته شده توسط FARZIN.ALONE در بخش دیگر زبان های اسکریپتی
    پاسخ: 3
    آخرین پست: دوشنبه 10 تیر 1392, 15:51 عصر
  3. پاسخ: 1
    آخرین پست: جمعه 28 بهمن 1390, 04:51 صبح
  4. سوال: چطور میتونم آدرس فولدر باز شده در ویندوز را پیدا کنم ؟
    نوشته شده توسط mohammad7484 در بخش C#‎‎
    پاسخ: 1
    آخرین پست: جمعه 30 مهر 1389, 14:10 عصر
  5. در شبکه ویندوز چطور میتونم توان نصب برنامه را به کاربران بدم
    نوشته شده توسط nasiri در بخش شبکه و Networking‌
    پاسخ: 0
    آخرین پست: شنبه 30 خرداد 1383, 08:31 صبح

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •