Questions tagged [pharo]
Pharo is an open-source Smalltalk environment. It is a derivative of Squeak and is MIT licensed with some original Apple parts remaining under the Apache 2.0 license.
913
questions
1
vote
1
answer
32
views
Overriding and extending trait methods in Pharo
Is it possible to extend trait methods by overriding them and calling super?
For example:
TMyTrait >> foo
"do something"
MyClassThatUsesTrait >> foo
super foo.
"...
4
votes
1
answer
113
views
Singleton pattern for multi-processing on Pharo 10.0 ( Smalltalk )
I can't pass the test below.
"SingletonTest"
testCurrent
| semaphore object1 object2 |
Singleton initialize.
semaphore := Semaphore new.
[
Processor yield.
...
1
vote
1
answer
67
views
How to use commandline tools from within pharo
I tried reading UFFI book but my basic knowledge isn't good enough.
So could someone please explain me how I can call an existing commandline tool from within pharo?
Lets say I'm building a little ...
1
vote
1
answer
356
views
How to show test results in the console?
In a GitHub Actions CI server I'm running ./pharo pharo.image test --fail-on-failure --junit-xml-output my-package to run a test suite. The problem is that when a test fails I just can see a console ...
2
votes
1
answer
62
views
How to log stack traces from seaside in deployed application
When developing in seaside the stack traces are printed into the browser. When deploying the application I don't want users to see this information but I would like a log of any stack traces on the ...
3
votes
3
answers
137
views
How is ordered a Dictionary in Pharo?
Let's say we have a loop that enters Associations to a Dictionary in a clear order:
| d |
d := Dictionary new: 10.
1 to: 10 do: [ :i |
d add: i -> (i + 9 printStringBase: 20)
].
d
When I ...
2
votes
1
answer
58
views
Can a child component use updateRoot: to add javascript
I'm using seaside 3.4.8 and a component seaside-plotlyjs to make a javascript plot. This component uses the updateRoot: selector to add in a link to the plotly javascript bundle. Everything is fine ...
2
votes
1
answer
112
views
Stream assigment in pharo
I have a problem here.
I have a data variable of type an OrderedCollection.
this variable shows me this when I do a DoIt: an OrderedCollection ('3c7lwmdva2b8jbt39ls4pz3sl' '3c7lwmbf36tamw1m45riirdze' ...
1
vote
2
answers
133
views
Generateing a method via source code in pharo
My goal is to generate a test method (automatically if we can say so). To do this, I need to send to a method that I named writeTestMethod., two parameters: the method I want to generate its test ...
1
vote
0
answers
68
views
Generate test method with their body in pharo
I advanced a little in my code but I find myself facing another problem for two days. I would like to generate a test method using only the source code. But I have no idea how to do it.
I have a ...
0
votes
1
answer
73
views
Class Test generate in Pharo via source code
I have a problem with my pharo code. I would like to generate a test class via the source code and that this class is visible in the packages of the browser system. But I don't know why it doesn't ...
2
votes
1
answer
145
views
initialize with pharo smalltalk
Here is a description of my problem. I have a Person class which has three attributes: lastname, name and birthDate.
Object subclass: #Person
instanceVariableNames: 'name lastName birthDate'
...
3
votes
1
answer
132
views
creating a CLI in Pharo
I'm having trouble figuring out how to pass arguments to a an object in the pharo image via the command line.
I know how to start the image from the command line by
pharovm image.image
But how can I ...
-1
votes
2
answers
133
views
Pharo dictionary
I have an issue and this is the result when i call one method in my code.
t do:[:i |
dict := Dictionary newFrom:{t->items}.
].
t is an
OrderedCollection(#name #lastName #birthDate)
...
0
votes
1
answer
143
views
Pharo initialize an object with an OrderedCollection
Indeed it is within the framework of a research. I'm trying to generate random values for the instance variables of an X object. So when instantiating the object, I replace the parameters of the ...
0
votes
1
answer
117
views
Pharo get all setter from a class
I am new in pharo. I have a problem. I want to get all setter from a class in this language. But i don't any idea for do that.
For example, we have ClassA that have a method like:
Object SubClass: #...
1
vote
1
answer
74
views
Retrieve an element of an orderedcollection in pharo
I have a difficult problem.
I have a method that return an OrderedCollection(an orderedCollection(String),an orderedCollection(String), an orderedCollection(Date)).
I want to have this result an ...
0
votes
1
answer
90
views
Convert Decimal number to Binary in Pharo
I'm trying to Convert a decimal number into binary using Pharo, but I'm having trouble with the recursive message. I figured I could do string concatenation of the values so that when I gave it the ...
0
votes
1
answer
46
views
how to install a specific metacello group from command line in Pharo 9?
I'm running this line which used to work as expected in Pharo 8, but doesn't in Pharo 9/10:
./pharo bootstrap.image metacello install tonel://./src BaselineOfPowerlang --groups=base
Instead of ...
2
votes
2
answers
110
views
Display array of objects as a table
I have an array of Candle objects as shown below:
Is there a way in Pharo to display the array in a tabular format?
| date | open | high | low | close |
|------------+------+------+-----+-------...
1
vote
2
answers
106
views
How to add horizontal line labels at end of line when using multiple plots in Roassal3
I'm trying to use Roassal3, in Pharo 10, to visualise multiple series of data. I've managed to draw the chart fine but want to label the lines. I tried using RSLegend to display the text with ...
2
votes
1
answer
77
views
Spec - How to edit the contents of a table in place
I have an SpTablePresenter and I would like to edit the cell contents.
In many frameworks it is possible to edit the contents of a table directly in place, without needing to open a new component (...
3
votes
1
answer
76
views
How to use a -Manifest package in Pharo Smalltalk after File-in/Install?
I just upgraded to the newest version of Pharo Smalltalk. Before doing so, I "File-outed" a package from my old version called My-Pharo - a package I use for various configurations and ...
3
votes
2
answers
361
views
how to write string literal with new lines in Pharo
How do you write a string literal with new line characters in Pharo 9? I tried the following but neither of them inserted the new line:
a := 'paragraph1\n\nparagraph2'.
a := 'paragraph1\\n\\...
1
vote
2
answers
73
views
How to make a Package with subgroups in Pharo 9
In Pharo 9, how do I create a package that has a hierarchy of sub-packages like in "Announcements-Core" where there is an expanding and collapsing arrow?
I thought that it might be based on ...
1
vote
2
answers
167
views
Pharo Smalltalk Method Execution
I have a few test cases that I need to write a method for, and how they execute the method is like this:
Planets with: aString , anotherString
Where "Planets" is a class and "with:&...
4
votes
2
answers
87
views
Pharo: #( $H $e $l $l $o ).'Hello' has no example in Finder
When I go to the finder and select "Examples" then I can't figure out how to find a method that turns #( $H $e $l $l $o ). into 'Hello'. Nor does MethodFinder new findMethodsByExampleInput: #...
2
votes
1
answer
45
views
Spec - use ctrl-S (or cmd+s) to save text entry
is there a way in SpTextPresenter and SpTextInputFieldPresenter to use ctrl+S (or cmd+S in mac) to save text entry?
Old pharo components (notably old spec but this comes since before, when components ...
3
votes
2
answers
442
views
pipenv Post-Install Actions
I'm using Python via Pharo/GToolkit's PythonBridge, which uses pipenv under the hood.
Things are kicked off via this built-in PythonBridge script (install_env.sh):
#!/bin/bash
cd "$(dirname "...
2
votes
1
answer
65
views
SQLite3Cursor object: how to access row values
I am fairly new to Pharo and trying hard to get a grip of it.
Installed the SQLite3 package and now I am trying to connect to local file based database.
I followed the Getting started tutorial of the ...
3
votes
1
answer
131
views
Spec - how to change the color (or background color) of a presenter
I want to change the background color of a SpTextInputFieldPresenter
e.g. to provide a visual feedback of the input, I want to react to whenTextChangedDo: and change the background color of the field ...
1
vote
1
answer
126
views
Adding Categories to Classes in Pharo 9.0 (Smalltalk)
I've very recently started learning Pharo Smalltalk and my first assignment requires me to add three categories to a class, but the problem is that any information I find on the web is written before ...
2
votes
1
answer
48
views
Spec - how to update a tree list keeping current selection?
I am displaying a tree and I need to add an element, but I want to keep the currently selected item.
If I do it like this:
oldSelectedItem := treePresenter selectedItem.
treePresenter
roots: ...
1
vote
0
answers
64
views
Pharo is re-writing code after compilation
I am going through the book "Learning Object-Oriented Programming, Design and TDD with Pharo" by Ducasse and Pollet.
I am using a Pharo 8.0.0 image as reported on the world help menu.
After ...
2
votes
1
answer
42
views
Spec - I want to replace the first presenter in a SpPanedLayout
Is that possible without needed to rebuild the whole presenter?
I am trying this code, but it does not work correctly:
self layout remove: (self layout children first).
self layout add: aNewPresenter.
...
3
votes
1
answer
50
views
Spec - horizontal panel with progress bar taking all the space in the middle
I want to create a row of three elements a label, a progressbar and a second label. To do this I've used this code:
(SpBoxLayout newLeftToRight
spacing: 15;
add: secondsPassed expand: false;
...
2
votes
1
answer
191
views
How to create a new source file in Pharo?
I downloaded the Pharo launcher and stable appimage for version 9.0 in Windows 10. Now I want to try a hello world program, but I can't see a "create new file" option.
How do I create a new ...
4
votes
1
answer
48
views
Does Pharo support home (~) as part of a path?
I am trying to use a path relative to home directory (~/.ssh/id_rsa.pub) in Pharo 8 but it does not work. For example:
'~/.ssh/id_rsa.pub' asFileReference exists ==> false
and the path is
'~/....
2
votes
2
answers
209
views
It's possible to interact with opencv and screen outside vm window?
I worked with smalltalk as hobby when Pharo born. A lot of years passed without touching it, and I'm sure a lot of things happened in smalltalk world. Now I have some projects in my mind and my main ...
3
votes
1
answer
98
views
Elements from collection get truncated when printing - Smalltalk
I am extremely new to Smalltalk, so please excuse me if I am implementing this solution incorrectly.
I'm reading a table from a txt file that looks like this:
1 3 5
2 4 7
55 30 50
I am reading the ...
1
vote
1
answer
112
views
Pharo: download file in parallel chunks
I'm trying to download a large file in chunks, with each chunk downloaded in parallel with the others. All chunks would be combined at the end.
However, from my understanding, Pharo's basic threading ...
0
votes
1
answer
103
views
XPath 1.0 trace ONLY element names at top nodes along path
I edited this for clarity with a much clearer example.
interesting XPath problem I have not found an answer for.
"I would just like to trace the path from the top of the tree to a leaf without ...
3
votes
1
answer
379
views
Write code computes the average of all the even integers in an array. with pharo smalltalk language
Solve the assessment in Pharo Smalltalk and please loop the whole code in two ways whileTrue: and do loops.
Here is what I tried but it gives me a wrong answer.
| x y z count elem sum |
x := #(84 45 ...
0
votes
1
answer
329
views
How to Create Methods in Pharo
I am am new to programming and currently learning Pharo Smalltalk. However, I got to a part of the book I am using (LearningOOP) and I am stuck at "Adding a setter method". The exercise is ...
12
votes
2
answers
502
views
Smalltalk: what's the difference between "&" and "and:"
I just started learning Smalltalk at uni.
I would like to know the difference between the messages & and and: (just like | and or:)
3
votes
1
answer
301
views
A new Pharo version was launched. What do I do with my old images?
I noticed Pharo 9 was released past month (july 2021). I have several Pharo 8 images with packages and classes I created while learning programming in Pharo. Is it possible to just update the old ...
6
votes
1
answer
234
views
Talking a slice of a string in Pharo smalltalk
I have a string an I would like to be able to take a substring from the middle of it. For example for the string 'abcdefg' I want to get 'cde' (but the exact start and stop could be arbitrary). I have ...
4
votes
1
answer
121
views
Image corrupted after longer coding session
i'm rather new to pharo and I just started another new pharo project (on version 9) and lost my image as the process crashed upon saving.
I cant even load the image anymore.
I have all the changes ...
6
votes
1
answer
96
views
Do classes like UndefinedObject behave like a singleton in Pharo
I am learning Pharo and I want to understand if classes/objects like nil which belongs to UndifnedObject class have only 1 instance and act like a singleton, or is a new instance made every time we ...
3
votes
1
answer
194
views
What's wrong with Iceberg/Pharo8 in Windows?
I'm trying to setup a Pharo8 image in Windows 10, using a git repo I cloned manually, but pharo gives a strange error. The following code works fine on linux, but fails in Windows (I've tried both Git ...