 One specific part of this B-Ware project is Toga. And that's what you have to know about that. Hi, everyone. Thank you for being here. I'll be sharing about B-Ware and Toga project, which is one of the projects under B-Ware suite. I'm Paul. I'm a developer. And at work, I use .NET and Microsoft stuff. And outside, I use Python, R, and the rest So that is my GitHub. You can check out my work in GitHub. And then that's also my feature. So why do we have this? So recently, early this month, there was PyCon Australia. It was held in Melbourne. So usually, PyCon have this. After the main conference, they usually allot two days for Sprint. So Sprint 1 and Sprint 2. And I joined two projects. One is MicroPython. And then the other one is B-Ware. So this Sprint is an avenue for enthusiasts, developers like you, and anyone who came to the conference to be able to contribute to open source. So one of the open source projects that I work on is B-Ware. So what we're going to tackle today or in this session are we'll delve into three things. We'll look into what B-Ware is. So that at least you'll get to know what Toga is later because it's one of the projects inside of B-Ware Suite. And then after that, I'll show you what happened in the Sprint. Let's say if you want to extend B-Ware or extend Toga project later, how should you go about it? And then we'll just wrap up. So yeah, so this is based on sharing. I didn't dig deep much into the framework, but I'll share what I have explained so far during the Sprint. So what is B-Ware? B-Ware is a collection of projects that can help develop, debug, and launch Python software. So it's a collection of various things. It can include tools that enable Python to run on different devices like Windows, Apple Mac, Android, phone, iOS. And it's also include packaging libraries so that you can develop your Python application and then have a way to deploy it in the various platforms. And then libraries that accesses native widgets. Native widgets in Windows using botnet framework. Native widget in Android using Java. And also I think in Mac OS, I think they use something called Tocowa. And tools to develop, debug, analyze, and deploy. So it contains a number of other things like converting from Python to Java, converting from Python. So they categorize this collection of projects into six categories. One is applications, which is if it's a standalone project under the B-Ware suite. So the icon that you can see here is Podium. It's an open source project under B-Ware that is used to do presentations. The one that you can see on the tools, actually, under the tools, if you click that in the website, there are several of them. But the one that I can highlight is at least this one. This one, they call it B4. B4 is in BEE4 because after you build or after the deployment, you want to have checks like, is my code meeting the code in the standard? So that's B4. So it's B4. And then you see the other icon, which is it looks like a suitcase or briefcase. Briefcase is our packaging library so that the idea is you package your application, you go to the Windows building, to the Linux building, the Android building, and then have it deployed there. So that's briefcase. And then the library, which is the one that we will be digging into further later, that's the Yak. That's the mascot for Toga. Why do they call it Toga? Because in Rome, they wear Toga. That is the library that is used so that when you develop your Python application, that enables you to run your Python application as a native equivalent. Let's say if you deploy it to Windows, it will run as a dotnet application. If you deploy it on your phone in Android, it will run as a Java application. Of course, that wouldn't be possible if you don't have bridges. Bridges allow you to convert your Python code into another language that is supported in that platform. So if you click here, there are like two popular converters or transpilers. This one is called Batavia. If you search like Australian history, it's about like a, yeah, there's a hidden story to it. I'll leave it to you to explore. So this Batavia is the one that converts your Python code into JavaScript. And then this one, VOC, that's the library that converts your Python code into Java. This is the one that is used when you deploy your application into Android. Because in Android, we convert our application into Java so that it can run in the ecosystem. So it makes use of templates so that, a while ago, we discussed briefcase, right? So when you deploy to an Android application, basically it uses like a cookie cutter so that it will generate the Android Studio project so that it will be able to deploy on the Android platform. And then, of course, there are other supports if it's intended to Mac OS and so on. So, but for this session, we'll dig more into Toga because that's where I contributed during the conference. So what is Toga? Toga is Python-native and OS-native GUI toolkit. Why Python-native? Because you don't have to know, let's say if you're developing a Toga application, you don't have to know C-sharp or .NET. You don't have to know Java. You don't have to know the other OS. You just develop it up in Python and if you want to deploy it in Windows as a .NET application, you just, right? And then deploy and it will run as .NET. If you develop, if you want, instead of your application to run on mobile, you just use Toga to run it as an Android application. So that's why it's, what you call this, it's interesting. So native widgets, not themes. This is one of the sort of philosophy that they try to adapt because you can see in other frameworks there are already existing applications such as Electron. You write in JavaScript and you can run in Windows and Linux and other operating systems. Let's say if you run, anyone here heard about Xamarin? You write in C-sharp and you can deploy both in iOS and Android and so on. But for this, what we want to do is, you write in Python, but it should run as a native application. Anyone here, anyone, any Game of Thrones fans here? It's like Arya wearing a mask, right? But when Arya wears a mask, it's still Arya. It's not really the person. But what we have here in Toga, you develop in Python and it runs as the real person in that particular target. So it's different. It doesn't, it looks as a native application because it is a native application. It's not a mask, it's not a covering. So abstract the broad concepts. So abstract the broad concepts meaning, with that in mind, one develops application in Python, but when it deploys, there's something that we are delegating. Let's say if you develop a widget like a button or a text box, this button or text box or let's say the menu will have their own interpretation in the particular target that you're targeting for. For example, when you're developing a menu, a quit button, right? A quit button, let's say in a Windows application, you'll find it under file and then do the quit, right? That makes sense if you're developing for a Windows application. How about if you're developing Mac? Do you have any Mac users here? Where is your quit button located? In the command queue or in the, they call it in the application menu. That's what they said. So different application may have different implementation of a certain concept. So what Toga allows you to do is it allows one to, I just want to specify, I want to have a quit button or a quit approach in my application, but delegate how the quit button will look like, where it will be located in the platform that I'm targeting. It's Python native and it embraces mobile because I think currently the frameworks that I've seen, at least Electron, it's mostly for desktop applications. Xamarin, I think it's mostly for mobile applications. You can develop in C-Sharp, deploy in iOS and Android. But Toga, Toga can do everything. Develop your application in Python. If you want to deploy it as a desktop application, Windows, Linux, Mac OS, it's possible. Not only that, if you want to deploy your application into mobile platforms such as iOS and Android, it's possible. And not only that, what if you want your application that you just developed to run as a web application? It can run as a Django application also. But we're in early days, so we're going to go through it. So Toga, these are the widgets supported by the platform. Of course, if you're using a widget that is not existing in your target platform, it's pretty hard, it won't work. So if you want to run, let's say, like maybe three or four platforms, when you develop your Toga application, you need to ensure that the widgets that you're using in your application are supported in your target platform. So you may ask, what's the current state of Toga? So let me just, I don't have the, let me just connect to the internet. It's not yet there there in terms of maturity. But at least when I think of it, when I was explaining to you the idea, this matures, I think it's going to be a very, very interesting project. Currently, this is the status that we have in terms of the availability of widgets. So you can go to, I place, I'm going to share the slides later so that we can, so currently you have iOS, Win32 web, and Django, I think this is for iOS, right? If you wonder why there's so much support in Cocoa, I think Russell, Russell, Keith McGee is the founder of, and founder of the V benevolent dictator, like the benevolent dictator for this project, I think he's using Mac also, and GTK for Linux, and then Android. So currently, other platforms don't have support, but we're working on it. At least the team is working on it, and then it's an open source project. So let's say you're expert in, if you're expert in Django, or let's say you want to contribute on the Django side of things, want to develop widgets on Linux or Mac OS, then check the Toga website on how to contribute. I'll show you later anyway on how to do that. By the time maybe next year and so on, we will be able to build up the rich target of this ecosystem. So the one, the particular one that I developed during the sprint is stable. So as you see in here, this table was only present in Cocoa and GTK, GTK meaning Linux. So during the sprint, I tried to help make the table available on Windows as well. Let's go back. So this is the state of the Toga widgets, and then we'll do a sort of demo for now. So I'm going to run at least both Linux and Windows. So at least you can see the sort of difference. I'm using Bash on the Ubuntu on Windows. It's too small, I'll need to, how about this? Good enough or can I do, it's good, okay, so I'll just, so earlier I did a virtual environment for, so I did a Linux virtual environment. I installed, pip install Toga and then so that I can run a Toga application here. So how does a Toga application look like? Well, I'll just show a little bit. Is the font good enough? So for a simple application, that's the whole code, you just import Toga and we are using event handlers for our botan. Basically we just print hello whenever this event handler is called. This is our main program. So this botan is implemented in various targets. So you have, if I do Toga botan, if this program runs in Windows, it will invoke a botan from .NET. If I run this program in Linux, it will invoke from DTK. Yeah, and then this is our start up application. So we just call DLD to the DTK function. So how do we run this? Okay, okay, sorry. Thanks, thanks. Okay, so I'm using, what's the call this? Bastion of Buntu in Windows, I need to export. So this is the botan. So it's running in Linux, it's me. This is Bastion of Buntu in Windows. So we're running Ubuntu 16, I think. So I'll just drag this here. So we have an event from the botan, right? So if I click here, you see the hello on the side. So this is a Linux application. What happens if I run it as a Windows application? So it's going to be the same thing. It's just that I need to create another virtual environment and then load Toga. So here in the command line, I'll just, same thing, same command. Instead it will run as a .NET application. So this is now a .NET. So same thing, you can still do the hello. So here, Toga botan, I explained a while ago, it has its own application. But this is too simplistic, right? How does it, if you have multiple botans and text boxes, how does it look like? So I'll just show you another example. So Toga works like, in terms of layout, it works like flex boxes. So you create the botan or the widgets first. Once you have the widgets created like this one. So here, what I'm doing here is I created a box, which serves as a container. So you have a C box, which is like our Celsius box where we put our widgets that is related to Celsius later. We're going to build a Celsius to Fahrenheit converter. So whatever is related to Celsius, we'll put it in the C box. Fahrenheit box, we'll put it there. And then the main box, which is a Toga box to put everything together. So once I have declared that, for each of the widgets that I'm going to use, I'm going to create like text input for that particular widget label, and then the other values as well. And then this one is, if I want to use a handler for the botan later. So here, after you've declared all your widgets, you need to add them sequentially. So here I'm adding the input, which is the input for the Fahrenheit, and then the label, the label later. And then that will be part of the F box. And then I do the same for the Celsius. And then once I have the F box and the C box, I put that in the mother box. And then that's how we compose the Toga application. So if I run this, it will have something like this. So you type this one. So that's sort of how it will look like. Now, the second question is, this is okay. This is okay if you want to just write a Toga application and then just run. What if you want to sort of, you see the missing widgets a while ago, right? If you want to contribute or to add more widgets into the Toga project, how can you, how should you be able to do it? So Toga is part of GitHub. So you have, yeah, so you just go here and then once you clone the Toga widget, then you'll have the code in hand also. So I'll just show you a bit. I won't dig much further. I will save the demo for it next time. But at least you'll get some idea on how it will look like. So here, Toga. So this Toga folder is the one that I just clone. And then here, let me go to at least this. So here it's composed of different platforms that Toga is able to deploy to. So you have GTK plus Django, TVOS, WatchOS, Web, Win32, WinForms. So during the sprint last time when we had in PyCon, what I did was I checked the GTK because we know a while ago that table is already implemented in the Linux platform. So GTK under GTK, you have Toga GTK and then widgets. You have the list of widgets that is available for that platform. So what I did was I checked the implementation of table there. So basically for table, it's like two things that you just need to ensure. How the table is instantiated, which is, this is the way that they do it in GTK. And then you need to provide an interface called insert so that when you insert to the table, the rows, how that target is able to handle. So that's the sort of interface that you need to build. This is what they did in GT in Linux. Now, my task is to be able to extend this widget to be able to work also on Windows. So what I did was I just sort of copy the table and then I just add the table inside widgets this is under WinForms. So in WinForms, I have this table.py and then I provided how to create the table object as well as the interface. But as you notice here, it's not the Linux application anymore. Under the hood, and I'm not sure if anyone knows about, there's another library called PythonNet. PythonNet allows your code to be converted from Python to .NET and vice versa. So under the hood, it's using that library. So now here, if you can see, this is WinForms that data gives you that is by the help of PythonNet library. So we're now able to access the .NET API using this. So once you have this, you'll be able to have your own implementation of the table object. I won't go through deep into this because of time constraints, but at least you get an idea on how it looks like. So just going back to the summary. So in summary, Beware is really a big project. If you ask me them with regards to maturity, I think it might not be there yet. In terms of promise, it's really, really, if it works, it's really great because you can just write your application in Python and then deploy it anywhere you want. But of course, execution is another thing. Execution, I think, is, they're still in the process of developing the widgets. But of course, I mean, there's a dedicated team that is looking into this, but during Python conference, they usually hold spin so that people can also contribute in developing such widgets. And Toga, that's a project under Beware that is dedicated for that particular GUI toolkit. Now, if you ask, how can I help? You can go to this link. So there are like, it doesn't matter if you're an expert or not. If you want to contribute something, there's something for everyone. So there are like for first time contributors, code contribution, and then platform usage. If you want to test something, let's say you just want to run the Toga application in your application. Let's go through the tutorials. If you face any issues, just feedback as an issue in GitHub, or there's a Gitter as well. So PyBee Gitter, you can just check that out. And then if you don't want to code, they are also accepting a membership which helps the team to focus more on the development. So yeah, that's it for Beware and Toga. For this, because it depends on that platform as well. Because let's say for, if you're targeting that net, it will be compiled or be transformed into the target application. So that net will have its own garbage collection on that side. It's just that after the conversion you're delegating, it's not running in Python anymore, it runs as a dot net. So whatever approaches for garbage collection of that platform, it will be done in that way. So they have another project, the one that I showed you a while ago, but I don't have time to demo. We have this thing called GIF case. So if this is like, if I want to deploy it on Windows, for example, this is the command. So I already have a develop app.py that contains the Toga and then the widgets. I place that in a certain folder and then I run this setup. What this setup do, it will create another folder called Windows. Once this setup is done, it will create an MSI. And then that MSI, you can give to your friends and then they can install it as a dot net application. This is the same approach to other platforms. So the Windows here, you can replace it with Android, Linux platforms. I tried Android the other day and today, I think if you run it on Mac OS, I think it might work because Russell, the founder, he used Mac. I tried it a while ago in Windows. It has some sort of, it's not that smooth yet. So there are like some things that need to be considered. But at least Windows and Linux, I've tried and both of them work because this one has to be considered. You saw a while ago, right? When we are trying to interpret, there will be interfaces for each of the platforms. When I develop a button, when I develop a certain menu, when I use that widget, that particular platform is doing the sort of implementation. So when I, let's say if someone is using Async.io on Python side, then the target application has to be able to interpret that. But if it's not coded then, that's why when we develop widgets for this, then there are certain things that we need to consider as well. Ah, good question. For this, at least for this, when I, I don't have time to demo, but I can debug it using Visual Studio Code. So what I do is, there's a command that you run in the command line. So that when you do your VN, when you try to build your Toga, so that when you do the import Toga, it will use the one that you have in the current environment. And then here, I'll just show you a bit. So here, let's say for example, I'm using Visual Studio Code. I have this launch that we've done. If I do it like this, so this is in a particular, the particular Python path here is in a particular environment. So VN, virtual environment. So it will use that Python. So whatever libraries that is loaded in that particular virtual environment, that's the one that it will use. So when I build my Toga application and put it in that environment, when I run this, it will invoke the current code. So I can debug too. Or PDB, but I haven't tried because this one is Visual. So I can just, you know how easy it is. I can just do like this and then I can run the debug. Yeah, so I mean it's, people have like their own favorite tools and stuff. Any, there's a dedicated team. And in terms of contributions, I think they are welcoming contributions. This is what I tried to share here. So membership, I encourage membership for enthusiasts, professionals, and small businesses. So they have those kind of packages if you want to sort of support the project. I believe it's very, very great project. It's just that, of course, Arasel doesn't work on this full time because he has to, of course, everyone has to eat, right? So, yeah, sort of support themselves. But of course, code contribution is always welcome. There's another, you can explore here. There's another link to the code contribution if you want to contribute. I think this is like maybe an activity that community can take part in. We don't have, I don't think we have to wait for Picon sprints to be able to do sprints. If there's enough interest, I think you guys can organize sprints like Saturday Sprints or something so to be able to do to open for it.