A challenge for you!
Posted
#1
(In Topic #1075)
Guru

The text should contain only complete words on each line and no longer than 20 characters.
The string supplied could be anything from 3 to hundreds of characters. Excessive characters can be ignored.
The code I came up with is in the 'Create' routine below, it can be run in a Graphical Application.
I wondered if someone can come up with simpler code to do the same thing.
Code (gambas)
- BuildForm
- Create("Raspberry Pi 3 Model B+ Consists of : Black Pi3 Case 2B/3B Black Modular Rpi Plus Case Sd Card Cover Black Modular Rpi Plus Case Usb Hdmi Cover Raspberry Pi 3 Model B + Raspberry Pi Universal Psu 5 1V-2 Transcend 16Gb Microsd High Capacity Class 10")
- 'Create("DOUBLE FACEPLATE With stuff")
- 'Create("Box")
- s1 = sDesc
- s2 = sDesc
- s3 = sDesc
- .Height = 88
- .Width = 192
- .Arrangement = Arrange.Vertical
- .Padding = 5
- .H = 28
- .W = 100
- .Alignment = Align.Center
- .H = 28
- .W = 100
- .Alignment = Align.Center
- .H = 28
- .W = 100
- .Alignment = Align.Center
Posted
Guru

/comp/gb.qt4/paint/trimtext - Gambas Documentation
That's how i would do it, as simply as possible
make 1 label sized to 3 chars high then use Paint.TrimText or Paint.TrimRichtext to get an auto trimmed string.
possibly not good enough for your specific needs though.
Posted
Guru

Code (gambas)
- Inc iLine
- aLines[iLine] = sWord
- Label1.Text = aLines[0]
- Label2.Text = aLines[1]
- Label3.Text = aLines[2]
Posted
Guru

Code (gambas)
I get this…
Raspberry Pi 3 Model
B+ Consists of Black
Pi3 Case 2B/3B Black
Posted
Guru

I was hoping this type of question might persuade a few more to contribute, so if you have another solution, let us see it!
Posted
Guru

cogier said
Thank you, Bruce. I am looking at your code. It certainly contains one or two nifty bits of code I need to get my head around.
I was hoping this type of question might persuade a few more to contribute, so if you have another solution, let us see it!
hehe, yeah alternative methods are always cool to see
how about the Picture method i first spoke of…
Instead of a label i use a PictureBox and make an image for it simply using Pant.DrawRichtext() and Paint.TrimRichtext()
But i think it's not going to trim as you want?
So i set the tooltip to be the complete text
Code (gambas)
shows like this…
Or I can use the following after Paint.Begin() to make smaller font and fit more text …
Paint.Font.Size = 8
then I get this..
Posted
Guru

how about the Picture method i first spoke of…
Thanks, but I have managed to get Gambas to work with a Zebra Thermal Printer using gb.cairo to create a pdf document of 2" x 1" which I put in the /tmp folder. I can then print it by shelling the lp command.
It works well so I do not want to have to rewrite that part of the program to cater for an alternative method. If it ain't broke, don't fix it!
<IMG src="https://www.cogier.com/gambas/jtprint.png">
</IMG>(Your mods not yet included)
Posted
Guru

8-)
Posted
Guru

cogier said
how about the Picture method i first spoke of…
Thanks, but I have managed to get Gambas to work with a Zebra Thermal Printer using gb.cairo to create a pdf document of 2" x 1" which I put in the /tmp folder. I can then print it by shelling the lp command.
It works well so I do not want to have to rewrite that part of the program to cater for an alternative method. If it ain't broke, don't fix it!
<IMG src="https://www.cogier.com/gambas/jtprint.png"></IMG>
(Your mods not yet included)
Aah cool
well it was a fun challenge anyway
1 guest and 0 members have just viewed this.






