الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Muntjac

بدأه ahmed_youssef في 7 فبراير 2012 · 6 رد · 937 مشاهدة · في لغة Python
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Web Application GUI Toolkit

Muntjac is a translation of Vaadin to the Python programming language. It is similar to GUI toolkits for desktop applications, such as PyQT, wxPython and PyGTK. However, it can be used to create dynamic, browser independent, web applications. There is no need to write HTML, Javascript or RPC code, just server-side Python.

مكتبة مبنية على نفس اسلوب عمل (وكود) vaadin لبايثون... تطوير الويب بصورة جذابة وسلسة

تستطيع تحميلها والإطلاع على الأمثلة من هنا

http://www.muntiacus.org/

تم تعديل هذه المشاركة بواسطة ahmed_youssef في 7 فبراير 2012 في 07:40

1
(map share people)

فضلا لاتقم بمراسلتي من أجل أسئلة لها أقسامها في المنتدى حتى تعم الفائدة على الجميع وللحصول على إجابات أفضل من أعضاء أكثر خبرة.
Weblog
@bitbucket
@xmonader

#2

تسلم يا أحمد.

كم تختلف تلك المكتبة عن pyjama؟

سبحانك اللهم و بحمدك ، أشهد أن لا إله إلا أنت ، أستغفرك ربي و أتوب إليك

مدونتي

http://www.facebook.com/brmjt

#3

PyJamas هي Compiler ل Javascript و تشمل Port ل GWT "تقدر تقول مكتبات GWT لبايثون

أما Muntjac فهي Port ل Vaadin

https://vaadin.com/home

(map share people)

فضلا لاتقم بمراسلتي من أجل أسئلة لها أقسامها في المنتدى حتى تعم الفائدة على الجميع وللحصول على إجابات أفضل من أعضاء أكثر خبرة.
Weblog
@bitbucket
@xmonader

#4

و vaadin مبني على GWT.

هل الكود الناتج من Muntjac يترجم إلى أي شيء آخر أم يظل بايثون كما هو؟

مجرد إضافة: كود hello world

from muntjac.api import Application, Window, Label


class HelloWorld(Application):

    def init(self):
        """Init is invoked on application load (when a user accesses
the application for the first time).
"""
        # Main window is the primary browser window
        main = Window('Hello window')
        self.setMainWindow(main)

        # "Hello world" text is added to window as a Label component
        main.addComponent(Label('Hello World!'))

سبحانك اللهم و بحمدك ، أشهد أن لا إله إلا أنت ، أستغفرك ربي و أتوب إليك

مدونتي

http://www.facebook.com/brmjt

#5

الكود الناتج كود Javascript ^_^

(map share people)

فضلا لاتقم بمراسلتي من أجل أسئلة لها أقسامها في المنتدى حتى تعم الفائدة على الجميع وللحصول على إجابات أفضل من أعضاء أكثر خبرة.
Weblog
@bitbucket
@xmonader

#6

لتشغيل البرنامج السابق

from muntjac.api import Application, Window, Label
from muntjac.main import muntjac 

class HelloWorld(Application):
	def init(self):
		main=Window('Hello window')
		self.setMainWindow(main)
		main.addComponent(Label('Hello, World!'))


muntjac(HelloWorld, port=10000)

تم تعديل هذه المشاركة بواسطة ahmed_youssef في 19 أبريل 2013 في 01:23

(map share people)

فضلا لاتقم بمراسلتي من أجل أسئلة لها أقسامها في المنتدى حتى تعم الفائدة على الجميع وللحصول على إجابات أفضل من أعضاء أكثر خبرة.
Weblog
@bitbucket
@xmonader

#7

قمت بتعديل مثال Calc ليكون آلة حاسبة بنظام RPN

 

from muntjac.api import Application, Button, GridLayout, Label, Window

from muntjac.ui.button import IClickListener

class RPNCalc(Application, IClickListener):
    """A simple calculator using Muntjac."""

    def __init__(self):
        super(RPNCalc, self).__init__()
        
        self.inp=""
        
    def init(self):
        # Application.init is called once for each application. Here it
        # creates the UI and connects it to the business logic.


        # Create the main layout for our application (4 columns, 5 rows)
        layout = GridLayout(4, 5)

        # Create the main window for the application using the main layout.
        # The main window is shown when the application is starts.
        self.setMainWindow(Window('Calculator Application', layout))


        # User interface components
        self._display = Label('0.0')
        # Create a result label that over all 4 columns in the first row
        layout.addComponent(self._display, 0, 0, 3, 0)

        # The operations for the calculator in the order they appear on the
        # screen (left to right, top to bottom)
        operations = ['7', '8', '9', '/', '4', '5', '6',
                '*', '1', '2', '3', '-', '0', '=', 'C', '+']

        for caption in operations:
            # Create a button and use this application for event handling
            button = Button(caption)
            button.addListener(self)

            # Add the button to our main layout
            layout.addComponent(button)


    def buttonClick(self, event):
        # Event handler for button clicks. Called for all the buttons in
        # the application.

        # Get the button that was clicked
        button = event.getButton()

        # Get the requested operation from the button caption
        el = button.getCaption()[0]
        if el == "=":
            newValue=self.evalRPN()
            self.inp= " "
        elif el == "C":
            newValue= " "
            self.inp = " "
        else:
            self.inp += el + " "
            newValue=self.inp
            
        # Update the result label with the new value
        self._display.setValue(newValue)

    def evalRPN(self):
        
        op_to_func = {
            "+" : lambda x,y : x+y,
            "-" : lambda x,y : x-y,
            "*" : lambda x,y : x*y,
            "/" : lambda x,y : x*1./y,

        }

        def evaluateRPN(expr):
            stack=[]
            for tok in expr.split(" "):
                if tok in op_to_func.keys():
                    #pop the last 2
                    n2=stack.pop()
                    n1=stack.pop()
                    stack.append(op_to_func[tok](n1,n2))
                else:
                    if tok.isdigit():
                        stack.append(int(tok))
                    
            if len(stack) == 1:
                return stack[0]
        return evaluateRPN(self.inp)
        
if __name__ == '__main__':
    from muntjac.main import muntjac
    muntjac(RPNCalc, port=11000, nogui=True, forever=True, debug=True)

تم تعديل هذه المشاركة بواسطة ahmed_youssef في 19 أبريل 2013 في 02:57

(map share people)

فضلا لاتقم بمراسلتي من أجل أسئلة لها أقسامها في المنتدى حتى تعم الفائدة على الجميع وللحصول على إجابات أفضل من أعضاء أكثر خبرة.
Weblog
@bitbucket
@xmonader