4.2.1 Putting a background picture

Although the white background is nice, you may want to put your own background picture for Pharo. Just like you do in with the Operating System wallpapers. So, to do this you have two options:

1) Having a .jpg file in your image/changes directory with the name matching the theme name will load upon theme change (Watery 2.jpg for instance). The default Pharo images have Watery 2 as default theme. Thus, you should name the file "Watery 2.jog".

2) Evaluating the following code:

 World backgroundImage: (ImageReadWriter formFromFileNamed: 'pharoBackground.png') layout: #scaled

In this case, the file "pharoBackground.png" also has to be in the same directory where the image is. Of course, you can adapt it and put the whole (absolute) path to a file. For example:

 World backgroundImage: (ImageReadWriter formFromFileNamed: '/Users/mariano/Pharo/pharoBackground.png') layout: #scaled

User Contributed Notes

daliot.oh (9 April 2011, 6:17 am)

wow, the code and the quality of image is beautiful. This can be a good homework for the reader.

siguctua (21 May 2010, 1:56 am)

An advanced example, which loading a background images from public server,

and changing your background each minute.





| rx str url form |

str := (HTTPSocket httpGet: 'http://www.socwall.com/browse/index.php?wpLimit=1&wpSortby=8') contents.

rx := '.*(http\://.+tb_.+\.jpg).*' asRegex.

url := (rx matches: str)

ifTrue: [

str := (rx subexpression: 2)

copyWithRegex: 'tb_' matchesReplacedWith: '' ]

ifFalse: [ nil ].

url ifNotNil: [

form := ImageReadWriter formFromStream: (HTTPSocket httpGet: url).

World backgroundImage: form layout: #scaled





on: Error do: [:ex| ].

1 minute asDelay wait.

] repeat.


] newProcess name: 'Random background changer'; priority: Processor userBackgroundPriority; resume

Add a Note

Licensed under Creative Commons BY-NC-SA | Published using Pier |