This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
tuogex's profile picture

txUI - Elegant GUI Components With Built-in Window Management

Started by tuogex, 08 July 2014 - 11:23 PM
tuogex #1
Posted 09 July 2014 - 01:23 AM
txUI

txUI is a ComputerCraft library designed to make rendering user interfaces easy yet powerful. It does this with object oriented components.
Any time you want to draw a component in txUI, all you have to do is add the component to a parent; be that a list or a window. You only need to change the fields that you want to. Want to make a blue button? You can! Want to make a button that changes color every time you click it? You can! Don't want a scroll bar in your list? Change one field and it's gone!

As of v1.0.0, txUI also serves a window manager.

Please post suggestions for features; you can track the progress, submit bugs, and suggest features on the project's GitHub repository.

Supported UI Components

UI components will only be drawn once it is added to a window.

Button
Label
TextField
List
Checkbox
ProgressBar


An example showing just some of the supported UI components. Code for this example available here.

Demo
SpoilerAll these demos were made in 15 minutes or less!

Code for the login demo is available here.

Code for the windows demo available here.


Get txUI

Current version on Pastebin: tuzXZBiz

pastebin run tuzXZBiz
The script will create a file called txUI in the current directory.
GitHub: tuogex/txUI wiki
Note that files from the GitHub repository have the .lua extension.

Documentation

Find guides and tutorials here.
Find detailed function and parameter documentation on the GitHub wiki.

Releases

GitHub releases page

Spoilerv1.0.0 and onward - details and download
v0.5.0-beta - major - details and download
v0.4.0-alpha - minor - details and download
v0.3.1-alpha - minor - details and download
v0.3.0-alpha - minor - details and download
v0.2.0-alpha - major - details and download
v0.1.0-alpha - initial release
Edited on 21 October 2015 - 08:26 PM
SquidDev #2
Posted 11 July 2014 - 08:12 AM
I like it. It looks much more snazzy than most GUI APIs I've seen. I love the fact that you're using an OOP approach to this, particularly the event driven system. Looking forward to experimenting with it. Personally I wouldn't bother with a window, it just adds one more layer of code with normally little added functionality. But overall, this is some pretty nice code.
tuogex #3
Posted 11 July 2014 - 09:47 PM
I like it. It looks much more snazzy than most GUI APIs I've seen. I love the fact that you're using an OOP approach to this, particularly the event driven system. Looking forward to experimenting with it. Personally I wouldn't bother with a window, it just adds one more layer of code with normally little added functionality. But overall, this is some pretty nice code.
Thanks for the response. Initially this library was meant for a desktop environment where the window object would actually have a use. The DE never came to be, but I'm currently working on making the window act almost like an Android Activity to actually give it some use. I have regained some interest in this project and plan on adding some features as well as maintaining it.
nickname912 #4
Posted 13 July 2014 - 09:40 AM
Awesome api. I hope you continue develop it to something even more awesome.
tuogex #5
Posted 14 July 2014 - 06:16 PM
Awesome api. I hope you continue develop it to something even more awesome.
Thanks! You can follow my development progress on GitHub.
LDShadowLord #6
Posted 16 July 2014 - 11:20 PM
So, as something I think you should add. Maybe the ability to "inherit" traits from other objects of the same type. Then I can make default sets of windows or labels, etc. And immediately call them without needing to re-code them.
bigbrainiac10 #7
Posted 19 July 2014 - 04:45 PM
Hey, I'm currently using this API in a project of mine, which is great!

However, is there any way of forcing an update every few seconds or so, rather than each time an event happens (a click)

I need this because I want a label to be updated with the correct information gained via a peripheral (energy cell - openp)
Mr. Bateman #8
Posted 19 July 2014 - 05:09 PM
Hey, I'm currently using this API in a project of mine, which is great!

However, is there any way of forcing an update every few seconds or so, rather than each time an event happens (a click)

I need this because I want a label to be updated with the correct information gained via a peripheral (energy cell - openp)
Try os.startTimer( nSeconds )
After nSeconds, it creates an event "timer" and txUI should pick it up
bigbrainiac10 #9
Posted 19 July 2014 - 06:28 PM
Hey, I'm currently using this API in a project of mine, which is great!

However, is there any way of forcing an update every few seconds or so, rather than each time an event happens (a click)

I need this because I want a label to be updated with the correct information gained via a peripheral (energy cell - openp)
Try os.startTimer( nSeconds )
After nSeconds, it creates an event "timer" and txUI should pick it up

I was thinking that myself not long after I posted this.

I'm going to try it now.
bigbrainiac10 #10
Posted 19 July 2014 - 06:42 PM
Nevermind, I'm not sure how to implement it, I'm trying:

txUI.UIManager.appUpdate = function(self)
powerAvailable.text = tostring(cell.getEnergyStored(cellDirection))
end
but that prevents me from typing into the TextField components…

Any Ideas?

EDIT: Actually, I think that may be a bug tuogex, if you have something constantly updating a value in appUpdate, it will become impossible for you to enter into TextField components but still possible to click buttons and things.
Edited on 19 July 2014 - 08:51 PM
tuogex #11
Posted 21 July 2014 - 03:47 PM
Nevermind, I'm not sure how to implement it, I'm trying:

txUI.UIManager.appUpdate = function(self)
powerAvailable.text = tostring(cell.getEnergyStored(cellDirection))
end
but that prevents me from typing into the TextField components…

Any Ideas?

EDIT: Actually, I think that may be a bug tuogex, if you have something constantly updating a value in appUpdate, it will become impossible for you to enter into TextField components but still possible to click buttons and things.
I'll be looking in to this when I get back from California, thanks.

Edit: In the most recent release, the timer event is no longer handled (but is consumed). I tested this by queuing a 'txui_forceupdate' event every second, but was unable to reproduce the problem.
Edited on 25 May 2015 - 03:55 AM
achjaj #12
Posted 10 October 2015 - 03:29 PM
Hi, how can I change Label text?

P.S. Your API is fantastic!
H4X0RZ #13
Posted 10 October 2015 - 07:40 PM
Hi, how can I change Label text?

P.S. Your API is fantastic!

I would suggest to move to another GUI framework (like this one) because 1. this API is extremely old and not updated for a long time and 2. the creator of this API was last online some months ago = no support for the API.
tuogex #14
Posted 21 October 2015 - 07:48 PM
Hi, how can I change Label text?

P.S. Your API is fantastic!

Thanks a bunch! You can change the text of a Label by passing a a table with a value with the key 'text'.

txUI.Label:new({text = "Hello World!";})

Hi, how can I change Label text?

P.S. Your API is fantastic!

I would suggest to move to another GUI framework (like this one) because 1. this API is extremely old and not updated for a long time and 2. the creator of this API was last online some months ago = no support for the API.
It's been a while since I've updated this thread but I made some commits to the GitHub repo over the summer to add window management capabilities into txUI along with performance improvements and other features. I'll try to support the API as much as I feasibly can, but you're right; I'm not on these forums much.
dodecaflexagon #15
Posted 24 December 2017 - 01:19 AM
I like this API, especially the windows. Is it possible to change the size of the windows?
Never mind, shifting to a different API and some custom hard-code UI.
Edited on 24 December 2017 - 12:45 AM
Bomb Bloke #16
Posted 24 December 2017 - 01:45 AM
Given that the author hasn't logged in here for a couple of years, it's highly unlikely any additional features will be added.
LMongoose #17
Posted 31 December 2017 - 11:09 PM
hi, i am getting some errors when opening your example codes
window:94: Arguments must be the same length,…

Edit 1: solved :)/>
Edited on 01 January 2018 - 02:39 PM